diff --git a/CHANGELOG.md b/CHANGELOG.md
index c014458e0c0..85f3fb85043 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
**Bug fixes**
- Fixed EuiDataGrid height issue when in full-screen mode and with scrolling content ([#5557](https://github.com/elastic/eui/pull/5557))
+- 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)
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}