From effb9d9eef6e37831c486388eabd1f4e00655377 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 10 May 2021 10:37:52 +0800 Subject: [PATCH 01/16] fix: Dropdown.Button do not support mouseEnterDelay (#30452) close #30280 --- components/dropdown/__tests__/dropdown-button.test.js | 11 +++++++++++ components/dropdown/dropdown-button.tsx | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/components/dropdown/__tests__/dropdown-button.test.js b/components/dropdown/__tests__/dropdown-button.test.js index 451b07c868..80ed2586f4 100644 --- a/components/dropdown/__tests__/dropdown-button.test.js +++ b/components/dropdown/__tests__/dropdown-button.test.js @@ -64,4 +64,15 @@ describe('DropdownButton', () => { const wrapper = mount(); expect(wrapper.type().__ANT_BUTTON).toBe(true); }); + + it('should pass mouseEnterDelay and mouseLeaveDelay to Dropdown', () => { + const menu = ( + + foo + + ); + const wrapper = mount(); + expect(wrapper.find('Dropdown').props().mouseEnterDelay).toBe(1); + expect(wrapper.find('Dropdown').props().mouseLeaveDelay).toBe(2); + }); }); diff --git a/components/dropdown/dropdown-button.tsx b/components/dropdown/dropdown-button.tsx index 4af0a837fe..3d2f902baf 100644 --- a/components/dropdown/dropdown-button.tsx +++ b/components/dropdown/dropdown-button.tsx @@ -52,6 +52,8 @@ const DropdownButton: DropdownButtonInterface = props => { icon = , title, buttonsRender, + mouseEnterDelay, + mouseLeaveDelay, ...restProps } = props; @@ -63,6 +65,8 @@ const DropdownButton: DropdownButtonInterface = props => { trigger: disabled ? [] : trigger, onVisibleChange, getPopupContainer: getPopupContainer || getContextPopupContainer, + mouseEnterDelay, + mouseLeaveDelay, } as DropDownProps; if ('visible' in props) { From 7e8075b06b29dcbc9853e9d1aeb4b42fe9c04e47 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 10 May 2021 10:58:53 +0800 Subject: [PATCH 02/16] style: fix Rate focused style (#30451) * style: fix Rate focused style close #30449 * Apply suggestions from code review Co-authored-by: xrkffgg Co-authored-by: xrkffgg --- components/rate/style/index.less | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/rate/style/index.less b/components/rate/style/index.less index d5e9353be4..5c93a12d9d 100644 --- a/components/rate/style/index.less +++ b/components/rate/style/index.less @@ -27,21 +27,22 @@ display: inline-block; color: inherit; cursor: pointer; - transition: all 0.3s; &:not(:last-child) { margin-right: 8px; } > div { - &:focus { - outline: 0; - } + transition: all 0.3s; &:hover, - &:focus { + &:focus-visible { transform: @rate-star-hover-scale; } + + &:focus:not(:focus-visible) { + outline: 0; + } } &-first, From b2a35f06eb6d99a28d12776c3361c9f32a20a888 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 10 May 2021 12:04:26 +0800 Subject: [PATCH 03/16] chore: fix husky pre commit --- .husky/pre-commit | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..2205895642 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx --no-install pretty-quick --staged \ No newline at end of file From dd1475232966169d0a75d68f41fc0d67f6a88211 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 10 May 2021 16:19:56 +0800 Subject: [PATCH 04/16] fix: Table filterDropdown confirm closeDropdown (#30457) * fix: Table filterDropdown confirm closeDropdown close #30454 * add test case * improve demo --- .../table/__tests__/Table.filter.test.js | 43 +++++++++++++++++++ components/table/demo/custom-filter-panel.md | 2 +- .../table/hooks/useFilter/FilterDropdown.tsx | 15 +++---- 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/components/table/__tests__/Table.filter.test.js b/components/table/__tests__/Table.filter.test.js index 0f58ebc95f..deed9aa9c8 100644 --- a/components/table/__tests__/Table.filter.test.js +++ b/components/table/__tests__/Table.filter.test.js @@ -1513,6 +1513,7 @@ describe('Table.filter', () => { expect(wrapper.find('.ant-table-filter-column')).toHaveLength(3); }); + it('should pagination.current be 1 after filtering', () => { const onChange = jest.fn(); const columns = [ @@ -1562,4 +1563,46 @@ describe('Table.filter', () => { wrapper.find('.ant-btn-primary').first().simulate('click'); expect(onChange.mock.calls[1][0].current).toBe(1); }); + + // https://github.com/ant-design/ant-design/issues/30454 + it('should not trigger onFilterDropdownVisibleChange when call confirm({ closeDropdown: false })', () => { + const onFilterDropdownVisibleChange = jest.fn(); + const wrapper = mount( + createTable({ + columns: [ + { + title: 'Name', + dataIndex: 'name', + key: 'name', + filteredValue: name, + filterDropdown: ({ confirm }) => ( + <> + + + + ), + onFilterDropdownVisibleChange, + }, + ], + }), + ); + + wrapper.find('.ant-dropdown-trigger').first().simulate('click'); + expect(onFilterDropdownVisibleChange).toHaveBeenCalledTimes(1); + + wrapper.find('#confirm-only').simulate('click'); + expect(onFilterDropdownVisibleChange).toHaveBeenCalledTimes(1); + + wrapper.find('#confirm-and-close').simulate('click'); + expect(onFilterDropdownVisibleChange).toHaveBeenCalledTimes(2); + expect(onFilterDropdownVisibleChange).toHaveBeenLastCalledWith(false); + }); }); diff --git a/components/table/demo/custom-filter-panel.md b/components/table/demo/custom-filter-panel.md index 9c3a69021d..719af1a561 100644 --- a/components/table/demo/custom-filter-panel.md +++ b/components/table/demo/custom-filter-panel.md @@ -64,7 +64,7 @@ class App extends React.Component { value={selectedKeys[0]} onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])} onPressEnter={() => this.handleSearch(selectedKeys, confirm, dataIndex)} - style={{ width: 188, marginBottom: 8, display: 'block' }} + style={{ marginBottom: 8, display: 'block' }} />