mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 09:26:06 +08:00
fix: Transfer checkbox disabled error (#40048)
* fix: Transfer checkbox disabled error * add test case
This commit is contained in:
parent
c0ce8e5455
commit
4b4e7cb6f2
@ -20,6 +20,11 @@ const listProps: TransferListProps<KeyWiseTransferItem> = {
|
||||
dataSource: undefined as unknown as KeyWiseTransferItem[],
|
||||
};
|
||||
|
||||
const emptyListProps: TransferListProps<KeyWiseTransferItem> = {
|
||||
...listCommonProps,
|
||||
dataSource: [],
|
||||
};
|
||||
|
||||
describe('Transfer.List', () => {
|
||||
it('should render correctly', () => {
|
||||
const { container } = render(<List {...listCommonProps} />);
|
||||
@ -39,4 +44,24 @@ describe('Transfer.List', () => {
|
||||
render(<List {...listProps} />);
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('Checkbox should disabled when dataSource is empty', () => {
|
||||
const { container } = render(<List {...emptyListProps} />);
|
||||
expect(container.querySelector<HTMLLabelElement>('label.ant-checkbox-wrapper')).toHaveClass(
|
||||
'ant-checkbox-wrapper-disabled',
|
||||
);
|
||||
expect(container.querySelector<HTMLSpanElement>('span.ant-checkbox')).toHaveClass(
|
||||
'ant-checkbox-disabled',
|
||||
);
|
||||
});
|
||||
|
||||
it('Checkbox should not disabled when dataSource not is empty', () => {
|
||||
const { container } = render(<List {...listCommonProps} />);
|
||||
expect(container.querySelector<HTMLLabelElement>('label.ant-checkbox-wrapper')).not.toHaveClass(
|
||||
'ant-checkbox-wrapper-disabled',
|
||||
);
|
||||
expect(container.querySelector<HTMLSpanElement>('span.ant-checkbox')).not.toHaveClass(
|
||||
'ant-checkbox-disabled',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -238,7 +238,7 @@ const TransferList = <RecordType extends KeyWiseTransferItem>(
|
||||
|
||||
const checkBox = (
|
||||
<Checkbox
|
||||
disabled={filteredItems.length === 0 || props.disabled}
|
||||
disabled={dataSource.length === 0 || props.disabled}
|
||||
checked={checkStatus === 'all'}
|
||||
indeterminate={checkStatus === 'part'}
|
||||
className={`${prefixCls}-checkbox`}
|
||||
|
Loading…
Reference in New Issue
Block a user