diff --git a/CHANGELOG.md b/CHANGELOG.md index a754a65cbda..18a3f3500f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fixed a `EuiDataGrid` sizing bug which didn't account for a horizontal scrollbar ([#5478](https://github.com/elastic/eui/pull/5478)) - Fixed `EuiModalHeaderTitle` to conditionally wrap title strings in an H1 ([#5494](https://github.com/elastic/eui/pull/5494)) +- Fixed a `EuiDataGrid` issue where a focused cell would lose focus when scrolled out of and back into view ([#5488](https://github.com/elastic/eui/pull/5488)) **Deprecations** diff --git a/src-docs/src/views/datagrid/datagrid_example.js b/src-docs/src/views/datagrid/datagrid_example.js index db272b1635d..47a606c471c 100644 --- a/src-docs/src/views/datagrid/datagrid_example.js +++ b/src-docs/src/views/datagrid/datagrid_example.js @@ -358,8 +358,8 @@ export const DataGridExample = { in memory level {' '} to have the grid automatically handle updating your columns. - Depending upon the level choosen you may need to manage the - content order separate from the grid. + Depending upon the level chosen, you may need to manage the + content order separately from the grid.
  • diff --git a/src-docs/src/views/datagrid/datagrid_focus_example.js b/src-docs/src/views/datagrid/datagrid_focus_example.js index d4718725ddd..db960a9e8c5 100644 --- a/src-docs/src/views/datagrid/datagrid_focus_example.js +++ b/src-docs/src/views/datagrid/datagrid_focus_example.js @@ -93,7 +93,7 @@ export const DataGridFocusExample = { color="warning" title="A caution about turning off cell expansion when the width of the column is unknown" > - In general, you should turn isExpandible to false + In general, you should turn isExpandable to false only when you know the exact width and number of items that a cell will include. Control columns that contain row actions are a good example of when to use them. In certain scenarios, allowing multiple diff --git a/src/components/datagrid/body/data_grid_cell.test.tsx b/src/components/datagrid/body/data_grid_cell.test.tsx index 27763b0dcd0..76551df7129 100644 --- a/src/components/datagrid/body/data_grid_cell.test.tsx +++ b/src/components/datagrid/body/data_grid_cell.test.tsx @@ -10,6 +10,7 @@ import React from 'react'; import { mount, ReactWrapper } from 'enzyme'; import { keys } from '../../../services'; import { mockRowHeightUtils } from '../__mocks__/row_height_utils'; +import { DataGridFocusContext } from '../data_grid_context'; import { EuiDataGridCell } from './data_grid_cell'; @@ -31,31 +32,24 @@ describe('EuiDataGridCell', () => { rowHeightUtils: mockRowHeightUtils, }; - const mountEuiDataGridCellWithContext = ({ ...props } = {}) => { - const focusContext = { - setFocusedCell: jest.fn(), - onFocusUpdate: jest.fn(), - }; - return mount(, { - context: focusContext, - }); - }; - beforeEach(() => jest.clearAllMocks()); it('renders', () => { - const component = mountEuiDataGridCellWithContext(); + const component = mount(); expect(component).toMatchSnapshot(); }); it('renders cell buttons', () => { - const component = mountEuiDataGridCellWithContext({ - isExpandable: false, - column: { - id: 'someColumn', - cellActions: [() =>