diff --git a/components/transfer/__tests__/index.test.tsx b/components/transfer/__tests__/index.test.tsx index a9e8343603..6920c8bb83 100644 --- a/components/transfer/__tests__/index.test.tsx +++ b/components/transfer/__tests__/index.test.tsx @@ -496,10 +496,32 @@ describe('Transfer', () => { expect(onScroll).toHaveBeenLastCalledWith('right', expect.anything()); }); - it('should support rowKey is function', () => { - expect(() => { - render( record.key} />); - }).not.toThrow(); + it('support rowKey', () => { + const onSelectChange = jest.fn(); + + const Demo = () => { + const [selectedKeys, setSelectedKeys] = useState([]); + + return ( + `key_${record.key}`} + onSelectChange={(keys) => { + onSelectChange(keys); + setSelectedKeys(keys); + }} + /> + ); + }; + + const { container } = render(); + + fireEvent.click(container.querySelector('.ant-transfer-list-content input')!); + expect(onSelectChange).toHaveBeenCalledWith(['key_a']); + expect( + container.querySelector('.ant-transfer-list-content input')!.checked, + ).toBeTruthy(); }); it('should support render value and label in item', () => { diff --git a/components/transfer/hooks/useSelection.ts b/components/transfer/hooks/useSelection.ts index 1f594f9648..c2be5571bf 100644 --- a/components/transfer/hooks/useSelection.ts +++ b/components/transfer/hooks/useSelection.ts @@ -7,6 +7,10 @@ function filterKeys(keys: string[], dataKeys: Set) { return keys.length === filteredKeys.length ? keys : filteredKeys; } +function flattenKeys(keys: Set) { + return Array.from(keys).join(';'); +} + export default function useSelection( leftDataSource: T[], rightDataSource: T[], @@ -44,7 +48,7 @@ export default function useSelection( React.useEffect(() => { setSourceSelectedKeys(filterKeys(sourceSelectedKeys, leftKeys)); setTargetSelectedKeys(filterKeys(targetSelectedKeys, rightKeys)); - }, [leftKeys, rightKeys]); + }, [flattenKeys(leftKeys), flattenKeys(rightKeys)]); return [ // Keys diff --git a/scripts/post-script.js b/scripts/post-script.js index 7fd39745b8..831ebae788 100644 --- a/scripts/post-script.js +++ b/scripts/post-script.js @@ -37,6 +37,7 @@ const DEPRECIATED_VERSION = { 'https://github.com/ant-design/cssinjs/pull/108', 'https://github.com/ant-design/ant-design/pull/41993', ], + '5.6.2': ['https://github.com/ant-design/ant-design/issues/43113'], }; function matchDeprecated(version) {