fix: Transfer disabled should work correctly

* fix: fix #18848

* chore: add test case
This commit is contained in:
Jingsong Gao 2019-09-17 13:31:32 +08:00 committed by 二货机器人
parent 1acd7e2249
commit 7404a7ea32
2 changed files with 21 additions and 2 deletions

View File

@ -144,6 +144,18 @@ describe('Transfer', () => {
expect(handleSelectChange).toHaveBeenLastCalledWith(['a'], ['b']);
});
it('should not check checkbox when component disabled', () => {
const handleSelectChange = jest.fn();
const wrapper = mount(
<Transfer {...listCommonProps} disabled onSelectChange={handleSelectChange} />,
);
wrapper
.find(TransferItem)
.filterWhere(n => n.prop('item').key === 'a')
.simulate('click');
expect(handleSelectChange).not.toHaveBeenCalled();
});
it('should not check checkbox when click on disabled item', () => {
const handleSelectChange = jest.fn();
const wrapper = mount(<Transfer {...listCommonProps} onSelectChange={handleSelectChange} />);

View File

@ -68,7 +68,14 @@ class ListBody extends React.Component<TransferListBodyProps> {
render() {
const { mounted } = this.state;
const { prefixCls, onScroll, filteredRenderItems, lazy, selectedKeys } = this.props;
const {
prefixCls,
onScroll,
filteredRenderItems,
lazy,
selectedKeys,
disabled: globalDisabled,
} = this.props;
return (
<Animate
@ -84,7 +91,7 @@ class ListBody extends React.Component<TransferListBodyProps> {
return (
<ListItem
disabled={disabled}
disabled={globalDisabled || disabled}
key={item.key}
item={item}
lazy={lazy}