From d88556140cd6ab76ecbf732d1698efb09f2da1fe Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Mon, 24 Jan 2022 11:37:18 -0800 Subject: [PATCH 1/3] Fix cell header focus not correctly updating - when clicking to another header cell when a cell header popover is already open --- .../datagrid/body/header/data_grid_header_cell.test.tsx | 9 ++++++++- .../datagrid/body/header/data_grid_header_cell.tsx | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/datagrid/body/header/data_grid_header_cell.test.tsx b/src/components/datagrid/body/header/data_grid_header_cell.test.tsx index 1fa31638feb..e17c2f65a82 100644 --- a/src/components/datagrid/body/header/data_grid_header_cell.test.tsx +++ b/src/components/datagrid/body/header/data_grid_header_cell.test.tsx @@ -11,6 +11,8 @@ import { mount, shallow } from 'enzyme'; import { EuiDataGridSorting } from '../../data_grid_types'; import { DataGridSortingContext } from '../../utils/sorting'; +import { DataGridFocusContext } from '../../utils/focus'; +import { mockFocusContext } from '../../utils/__mocks__/focus_context'; import { EuiDataGridHeaderCell } from './data_grid_header_cell'; @@ -145,10 +147,15 @@ describe('EuiDataGridHeaderCell', () => { }); it('handles popover open', () => { - const component = mount(); + const component = mount( + + + + ); component.find('.euiDataGridHeaderCell__button').simulate('click'); expect(component.find('EuiPopover').prop('isOpen')).toEqual(true); + expect(mockFocusContext.setFocusedCell).toHaveBeenCalledWith([0, -1]); }); it('handles popover close', () => { diff --git a/src/components/datagrid/body/header/data_grid_header_cell.tsx b/src/components/datagrid/body/header/data_grid_header_cell.tsx index 880506e00df..f14e09a79a5 100644 --- a/src/components/datagrid/body/header/data_grid_header_cell.tsx +++ b/src/components/datagrid/body/header/data_grid_header_cell.tsx @@ -152,9 +152,10 @@ export const EuiDataGridHeaderCell: FunctionComponent - setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen) - } + onClick={() => { + setFocusedCell([index, -1]); + setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen); + }} > {sortingArrow}
From 5f7a109a700c2bfc371d6c2e17b1a33a01fbd31f Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Mon, 24 Jan 2022 12:16:51 -0800 Subject: [PATCH 2/3] Add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3042fa057f..dbd94bc9ed7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ - Added `sun` glyph to `EuiIcon` ([#5548](https://github.com/elastic/eui/pull/5548)) - Updated styles in `EuiDescriptionList` of `type` inline ([#5534](https://github.com/elastic/eui/pull/5534)) +**Bug fixes** + +- Fixed a focus bug in `EuiDataGrid` when clicking another cell header with an already-open cell header popover ([#5556](https://github.com/elastic/eui/pull/5556)) + ## [`46.0.0`](https://github.com/elastic/eui/tree/v46.0.0) - **[Beta]** Added `optimize` build as a lighter weight option more suited to production environments ([#5527](https://github.com/elastic/eui/pull/5527)) From e2009e135bcd6d0a5ce7859266a9d2258a54a632 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Tue, 25 Jan 2022 07:33:01 -0800 Subject: [PATCH 3/3] Changelog --- CHANGELOG.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46c036be6cf..2c2f5b17936 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,14 @@ ## [`main`](https://github.com/elastic/eui/tree/main) -No public interface changes since `46.1.0`. +**Bug fixes** + +- Fixed a focus bug in `EuiDataGrid` when clicking another cell header with an already-open cell header popover ([#5556](https://github.com/elastic/eui/pull/5556)) ## [`46.1.0`](https://github.com/elastic/eui/tree/v46.1.0) - Added `sun` glyph to `EuiIcon` ([#5548](https://github.com/elastic/eui/pull/5548)) - Updated styles in `EuiDescriptionList` of `type` inline ([#5534](https://github.com/elastic/eui/pull/5534)) -**Bug fixes** - -- Fixed a focus bug in `EuiDataGrid` when clicking another cell header with an already-open cell header popover ([#5556](https://github.com/elastic/eui/pull/5556)) - ## [`46.0.0`](https://github.com/elastic/eui/tree/v46.0.0) - **[Beta]** Added `optimize` build as a lighter weight option more suited to production environments ([#5527](https://github.com/elastic/eui/pull/5527))