Skip to content

Commit fa0c357

Browse files
authored
fix(Transfer): disable select all for disabled search results (#59121)
1 parent a06ff88 commit fa0c357

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎components/transfer/Section.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ const TransferSection = <RecordType extends KeyWiseTransferItem>(
304304

305305
const checkBox = (
306306
<Checkbox
307-
disabled={!dataSource.some((d) => !d.disabled) || disabled}
307+
disabled={!filteredItems.some((d) => !d.disabled) || disabled}
308308
checked={checkStatus === 'all'}
309309
indeterminate={checkStatus === 'part'}
310310
className={`${listPrefixCls}-checkbox`}

‎components/transfer/__tests__/index.test.tsx‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,29 @@ describe('Transfer', () => {
466466
expect(handleSelectChange).toHaveBeenCalledWith(['1'], []);
467467
});
468468

469+
it('should disable check all when filtered items are all disabled', () => {
470+
const { container } = render(
471+
<Transfer
472+
dataSource={[
473+
{ key: 'enabled', title: 'Enabled item' },
474+
{ key: 'disabled', title: 'Only disabled item', disabled: true },
475+
]}
476+
showSearch
477+
render={(item) => item.title}
478+
/>,
479+
);
480+
481+
const sourceSection = container.querySelectorAll('.ant-transfer-section').item(0);
482+
483+
fireEvent.change(sourceSection.querySelector('input[type="text"]')!, {
484+
target: { value: 'Only disabled item' },
485+
});
486+
487+
expect(
488+
sourceSection.querySelector('.ant-transfer-list-header input[type="checkbox"]'),
489+
).toBeDisabled();
490+
});
491+
469492
it('should transfer just the filtered item after search by input', () => {
470493
const filterOption: TransferProps<any>['filterOption'] = (inputValue, option) =>
471494
option.description.includes(inputValue);

0 commit comments

Comments
 (0)