diff --git a/docs/zh-CN/components/form/select.md b/docs/zh-CN/components/form/select.md index dcf1a20e7..23b69012a 100755 --- a/docs/zh-CN/components/form/select.md +++ b/docs/zh-CN/components/form/select.md @@ -1165,6 +1165,7 @@ leftOptions 动态加载,默认 source 接口是返回 options 部分,而 le | popOverContainerSelector | `string` | | 弹层挂载位置选择器,会通过`querySelector`获取 | | clearable | `boolean` | | 是否展示清空图标 | | overlay | `{ width: string \| number, align: "left" \| "center" \| "right" }` | | 弹层宽度与对齐方式 `2.8.0 以上版本` | +| showInvalidMatch | `boolean` | `false` | 选项值与选项组不匹配时选项值是否飘红 | ## 事件表 diff --git a/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap b/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap index a35e1df89..f8c8ffbaf 100644 --- a/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap +++ b/packages/amis/__tests__/renderers/Form/__snapshots__/transfer.test.tsx.snap @@ -6302,7 +6302,7 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = ` > @@ -6445,166 +6445,6 @@ exports[`Renderer:transfer with showInvalidMatch & unmatched do not add 1`] = ` -
  • -
    - - -
    - - - w - - -
    -
    -
    -
  • -
  • -
    - - -
    - - - x - - -
    -
    -
    -
  • -
  • -
    - - -
    - - - y - - -
    -
    -
    -
  • -
  • -
    - - -
    - - - z - - -
    -
    -
    -
  • diff --git a/packages/amis/__tests__/renderers/Form/transfer.test.tsx b/packages/amis/__tests__/renderers/Form/transfer.test.tsx index 3b58b2821..c21ebfdd5 100644 --- a/packages/amis/__tests__/renderers/Form/transfer.test.tsx +++ b/packages/amis/__tests__/renderers/Form/transfer.test.tsx @@ -969,6 +969,6 @@ test('Renderer:transfer with showInvalidMatch & unmatched do not add', async () expect(container).toMatchSnapshot(); - expect(leftItems()!.length).toBe(7); + expect(leftItems()!.length).toBe(3); expect(rightItems()!.length).toBe(4); }); diff --git a/packages/amis/src/renderers/Form/Transfer.tsx b/packages/amis/src/renderers/Form/Transfer.tsx index 17d5952b4..7dbca75f9 100644 --- a/packages/amis/src/renderers/Form/Transfer.tsx +++ b/packages/amis/src/renderers/Form/Transfer.tsx @@ -220,7 +220,10 @@ export class BaseTransferRenderer< ); if (!indexes) { - newOptions.push(item); + newOptions.push({ + ...item, + visible: false + }); } else if (optionModified) { const origin = getTree(newOptions, indexes); newOptions = spliceTree(newOptions, indexes, 1, { @@ -251,7 +254,10 @@ export class BaseTransferRenderer< ); if (!indexes) { - newOptions.push(value); + newOptions.push({ + ...value, + visible: false + }); } else if (optionModified) { const origin = getTree(newOptions, indexes); newOptions = spliceTree(newOptions, indexes, 1, { @@ -270,9 +276,13 @@ export class BaseTransferRenderer< (option: Option) => option.deferApi || option.defer )); - isTreeDefer === true || - ((newOptions.length > options.length || optionModified) && - setOptions(newOptions, true)); + if ( + isTreeDefer === true || + newOptions.length > options.length || + optionModified + ) { + setOptions(newOptions, true); + } // 触发渲染器事件 const rendererEvent = await dispatchEvent(