Skip to content

Commit

Permalink
fix: filterOption for transfer shouldn't depend on filterValue ant-de…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Tkachev committed Dec 30, 2022
1 parent 5f40fe8 commit a7c49ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/transfer/__tests__/search.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ describe('Transfer.Search', () => {

fireEvent.change(container.querySelector('.ant-input')!, { target: { value: ' ' } });

expect(filterOption).toHaveBeenCalledTimes(dataSource.length);
expect(filterOption).toHaveBeenCalledTimes(2*dataSource.length);
});
});
6 changes: 4 additions & 2 deletions components/transfer/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class TransferList<
getFilteredItems(
dataSource: RecordType[],
filterValue: string,
filterOption?: (filterText: string, item: RecordType) => boolean,
): { filteredItems: RecordType[]; filteredRenderItems: RenderedItem<RecordType>[] } {
const filteredItems: RecordType[] = [];
const filteredRenderItems: RenderedItem<RecordType>[] = [];
Expand All @@ -124,7 +125,7 @@ export default class TransferList<
const { renderedText } = renderedItem;

// Filter skip
if (filterValue && !this.matchFilter(renderedText, item)) {
if ((filterValue || filterOption) && !this.matchFilter(renderedText, item)) {
return null;
}

Expand Down Expand Up @@ -322,6 +323,7 @@ export default class TransferList<
showRemove,
pagination,
direction,
filterOption,
} = this.props;

// Custom Layout
Expand All @@ -335,7 +337,7 @@ export default class TransferList<

// ====================== Get filtered, checked item list ======================

const { filteredItems, filteredRenderItems } = this.getFilteredItems(dataSource, filterValue);
const { filteredItems, filteredRenderItems } = this.getFilteredItems(dataSource, filterValue, filterOption);

// ================================= List Body =================================

Expand Down

0 comments on commit a7c49ee

Please sign in to comment.