mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
Merge branch 'master' into docs/global-message
This commit is contained in:
commit
73246d99cb
@ -2079,6 +2079,44 @@ describe('Table.filter', () => {
|
||||
fireEvent.change(container.querySelector('.ant-input')!, { target: { value: '111' } });
|
||||
});
|
||||
|
||||
it('renders empty element when search not found', () => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
const { container, unmount } = render(
|
||||
createTable({
|
||||
columns: [
|
||||
{
|
||||
...column,
|
||||
filters: [
|
||||
{
|
||||
text: '123',
|
||||
value: '456',
|
||||
},
|
||||
{
|
||||
text: 123456,
|
||||
value: '456',
|
||||
},
|
||||
{
|
||||
text: '456',
|
||||
value: '456',
|
||||
},
|
||||
],
|
||||
filterSearch: true,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
fireEvent.click(container.querySelector('span.ant-dropdown-trigger')!, nativeEvent);
|
||||
act(() => {
|
||||
jest.runAllTimers();
|
||||
});
|
||||
expect(container.querySelectorAll('.ant-table-filter-dropdown-search').length).toBe(1);
|
||||
expect(container.querySelectorAll('.ant-input').length).toBe(1);
|
||||
fireEvent.change(container.querySelector('.ant-input')!, { target: { value: '111' } });
|
||||
expect(container.querySelector('.ant-empty')).toBeTruthy();
|
||||
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('supports search input in filter menu', () => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||
const { container } = render(
|
||||
|
@ -367,20 +367,21 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
|
||||
} else {
|
||||
const selectedKeys = getFilteredKeysSync() || [];
|
||||
const getFilterComponent = () => {
|
||||
const empty = (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={locale.filterEmptyText}
|
||||
imageStyle={{
|
||||
height: 24,
|
||||
}}
|
||||
style={{
|
||||
margin: 0,
|
||||
padding: '16px 0',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
if ((column.filters || []).length === 0) {
|
||||
return (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={locale.filterEmptyText}
|
||||
imageStyle={{
|
||||
height: 24,
|
||||
}}
|
||||
style={{
|
||||
margin: 0,
|
||||
padding: '16px 0',
|
||||
}}
|
||||
/>
|
||||
);
|
||||
return empty;
|
||||
}
|
||||
if (filterMode === 'tree') {
|
||||
return (
|
||||
@ -435,6 +436,16 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
const items = renderFilterItems({
|
||||
filters: column.filters || [],
|
||||
filterSearch,
|
||||
prefixCls,
|
||||
filteredKeys: getFilteredKeysSync(),
|
||||
filterMultiple,
|
||||
searchValue,
|
||||
});
|
||||
const isEmpty = items.every((item) => item === null);
|
||||
|
||||
return (
|
||||
<>
|
||||
<FilterSearch
|
||||
@ -444,26 +455,21 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
|
||||
tablePrefixCls={tablePrefixCls}
|
||||
locale={locale}
|
||||
/>
|
||||
<Menu
|
||||
selectable
|
||||
multiple={filterMultiple}
|
||||
prefixCls={`${dropdownPrefixCls}-menu`}
|
||||
className={dropdownMenuClass}
|
||||
onSelect={onSelectKeys}
|
||||
onDeselect={onSelectKeys}
|
||||
selectedKeys={selectedKeys}
|
||||
getPopupContainer={getPopupContainer}
|
||||
openKeys={openKeys}
|
||||
onOpenChange={onOpenChange}
|
||||
items={renderFilterItems({
|
||||
filters: column.filters || [],
|
||||
filterSearch,
|
||||
prefixCls,
|
||||
filteredKeys: getFilteredKeysSync(),
|
||||
filterMultiple,
|
||||
searchValue,
|
||||
})}
|
||||
/>
|
||||
{isEmpty ? empty : (
|
||||
<Menu
|
||||
selectable
|
||||
multiple={filterMultiple}
|
||||
prefixCls={`${dropdownPrefixCls}-menu`}
|
||||
className={dropdownMenuClass}
|
||||
onSelect={onSelectKeys}
|
||||
onDeselect={onSelectKeys}
|
||||
selectedKeys={selectedKeys}
|
||||
getPopupContainer={getPopupContainer}
|
||||
openKeys={openKeys}
|
||||
onOpenChange={onOpenChange}
|
||||
items={items}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -135,7 +135,7 @@
|
||||
"rc-dialog": "~9.4.0",
|
||||
"rc-drawer": "~7.1.0",
|
||||
"rc-dropdown": "~4.2.0",
|
||||
"rc-field-form": "~1.42.1",
|
||||
"rc-field-form": "~1.44.0",
|
||||
"rc-image": "~7.6.0",
|
||||
"rc-input": "~1.4.5",
|
||||
"rc-input-number": "~9.0.0",
|
||||
|
Loading…
Reference in New Issue
Block a user