-
Notifications
You must be signed in to change notification settings - Fork 859
[EuiDataGrid] Various footer fixes #5720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
df318b3
Fix focus fighting bug after moving a column and clicking its footer …
cee-chen 449ffb3
Footer docs example: remove expand button if footer cell is empty
cee-chen 730b173
Add Cypress tests
cee-chen e72ef0a
Add changelog entry
cee-chen d3db2fc
Address PR feedback
cee-chen 556016f
Merge branch 'main' into datagrid/footer-fixes
cee-chen 48cfc28
changelog
cee-chen 1cd438b
PR feedback: currency formatting
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
src/components/datagrid/body/data_grid_footer_row.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| /// <reference types="../../../../cypress/support"/> | ||
|
|
||
| import React, { useState, useEffect } from 'react'; | ||
| import { EuiDataGrid } from '../'; | ||
|
|
||
| describe('EuiDataGridFooterRow', () => { | ||
| const mockData = [10, 15, 20]; | ||
|
|
||
| const RenderCellValue = ({ rowIndex, columnId }) => | ||
| columnId === 'b' ? mockData[rowIndex] : null; | ||
|
|
||
| const RenderFooterCellValue = ({ columnId, setCellProps }) => { | ||
| const value = columnId === 'b' ? mockData.reduce((a, b) => a + b, 0) : null; | ||
|
|
||
| useEffect(() => { | ||
| if (!value) setCellProps({ isExpandable: false }); | ||
| }, [value, setCellProps]); | ||
|
|
||
| return value; | ||
| }; | ||
|
|
||
| // We need to set up a test component here for column ordering to work | ||
| const GridTest = () => { | ||
| const [visibleColumns, setVisibleColumns] = useState(['a', 'b']); | ||
|
|
||
| return ( | ||
| <EuiDataGrid | ||
| aria-label="Footer row tests" | ||
| columns={[{ id: 'a' }, { id: 'b', display: 'Total' }]} | ||
| columnVisibility={{ visibleColumns, setVisibleColumns }} | ||
| rowCount={3} | ||
| renderCellValue={RenderCellValue} | ||
| renderFooterCellValue={RenderFooterCellValue} | ||
| /> | ||
| ); | ||
| }; | ||
| GridTest.displayName = 'GridTest'; | ||
|
|
||
| it('renders a footer of total values', () => { | ||
| cy.mount(<GridTest />); | ||
|
|
||
| cy.get( | ||
| '[data-gridcell-column-index="1"][data-gridcell-row-index="3"]' | ||
| ).contains('45'); | ||
| }); | ||
|
|
||
| it('does not render an expansion button for the empty footer cell', () => { | ||
| cy.mount(<GridTest />); | ||
|
|
||
| cy.get( | ||
| '[data-gridcell-column-index="0"][data-gridcell-row-index="3"]' | ||
| ).click(); | ||
| cy.get('[data-test-subj="euiDataGridCellExpandButton"]').should( | ||
| 'not.exist' | ||
| ); | ||
| }); | ||
|
|
||
| // Regression test for #5720 | ||
| it('does not bug focus when moving a column and then clicking its footer cell', () => { | ||
| cy.mount(<GridTest />); | ||
|
|
||
| cy.get( | ||
| '[data-gridcell-column-index="1"][data-gridcell-row-index="-1"]' | ||
| ).click(); | ||
| cy.contains('Move left').click(); | ||
|
|
||
| cy.get('[data-gridcell-column-index="0"][data-gridcell-row-index="3"]') | ||
| .click() | ||
| .contains('45') | ||
| .click(); | ||
|
|
||
| // Note that the wait/timeout and multiple focused assertions are required for | ||
| // for this specific bug which bounces focus rapidly between cells, as otherwise | ||
| // Cypress re-tries until it happens to be on the cell with correct attributes | ||
| cy.wait(50); | ||
| const checkFocusedCell = () => { | ||
| cy.wait(1); | ||
| cy.focused({ timeout: 0 }) | ||
| .should('have.attr', 'data-gridcell-column-index', '0') | ||
| .should('not.have.attr', 'data-gridcell-column-index', '1'); | ||
| }; | ||
| checkFocusedCell(); | ||
| checkFocusedCell(); | ||
| checkFocusedCell(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| **Bug fixes** | ||
|
|
||
| - Fixed `EuiDataGrid` footer cell focus bugging out after moving its column |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.