Skip to content
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

[EuiDataGrid] Various footer fixes #5720

Merged
merged 8 commits into from
Mar 18, 2022

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Mar 14, 2022

Summary

There's 1 main bugfix in here and 2 documentation fixes, so I recommend following along by commit.

Footer focus bug:

Repro steps:

  1. Go to http://localhost:8030/#/tabular-content/data-grid-schema-columns#footer-row
  2. Move the amount column to the left or right
  3. Click the amount column's footer cell
  4. Notice the focus now bouncing between the footer cell and its previous position:
    before

Footer cell

@cchaos noted in #5710 that it felt odd for empty cell footers to have an expansion button.

Before:

After:

This isn't something we can enforce at the EUI level, but we can add this it as an example/recommendation for consuming applications with footers to use.

Checklist

  • Checked in Chrome, Safari, Edge, and Firefox~
  • Added or updated jest and cypress tests
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@cee-chen cee-chen force-pushed the datagrid/footer-fixes branch from 7ff929d to a3fe7fd Compare March 14, 2022 22:31
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5720/

@cee-chen cee-chen requested a review from chandlerprall March 14, 2022 23:33
@cee-chen cee-chen marked this pull request as ready for review March 14, 2022 23:33
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5720/

Comment on lines 82 to 83
// Turn off the cell expansion button if the footer cell is empty
if (!value) setCellProps({ isExpandable: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this somewhere in the example text? Something as simple as:

When rendering footer cell values, we encourage turning off cell expansion on cells without content with setCellProps({ isExpandable: false }).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, this really feels like the DataGrid should know if any cells are empty, to turn off cell expansion by default. But I'll create a specific issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data grid inherently has no concept of the actual underlying data that's being rendered, and it would be non-trivial to change that architectural direction. I know there are a few open issues about that behavior however, e.g. #4108. @chandlerprall do you mind expanding on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from being able to detect if they're empty (I do have some thoughts there), I don't know if we can define empty in a meaningful way. I can imagine a waffle chart (and maybe ML has one of theirs implemented with the data grid?) where the only "content" is color, but expanding the cell would provide additional information.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it not know if the popoverContents is empty?

Copy link
Contributor Author

@cee-chen cee-chen Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No - popover contents now use the same paradigm as renderCellValue, we ask for a render function and are unopinionated about what's in it. Additionally, we don't render the cell popover until after the expand button has been clicked so we can't easily inspect the contents before determining whether the button should even render. Pre-rendering popovers to inspect contents feels like an anti-pattern to me and could have a negative performance impact.

I also think it's worth hashing out what we define as "empty". We can examine the cell content ref's innerHtml, but what happens when the consumer passes a space or empty <p> or <br> tag? We can examine the cell content ref's innerText, but what happens when the consumer has passed an image, chart, or some other media without text nodes?

In the end what I think this boils down is that the consumer knows their content better than we do, and while we can try to enforce things rigidly, ultimately nothing is foolproof and providing guidelines is sometimes the best we can do. At a quick glance it also looks like there's only 2 tables in Kibana currently using footer rows, so it should be fairly quick to do an audit of them if we needed to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This. This is "empty" 🤣
Screen Shot 2022-03-15 at 18 21 29 PM


But I get it, the answer right now is "we can't", but I'd strongly suggest figuring out if we "can" somehow, at some point. We all know consumers who use plug & play components do not think twice after just handing down their data. They just think "That's how its supposed to be because that's how the component is built"

src-docs/src/views/datagrid/footer_row.js Outdated Show resolved Hide resolved
src-docs/src/views/datagrid/datagrid_footer_row_example.js Outdated Show resolved Hide resolved
…cell

Using a cell `key` with a column ID causes the cell node reference to move, instead of the cell/node reference staying in place and cell props changing (which is how react-window behaves)
@cee-chen cee-chen force-pushed the datagrid/footer-fixes branch from 1763ad2 to e72ef0a Compare March 15, 2022 20:26
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5720/

@cee-chen cee-chen requested a review from cchaos March 17, 2022 20:20
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5720/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM; can not reproduce focus fighting between 2+ footer cells any more

One ask for the GH comment to be a code comment, but otherwise 🚢

@cee-chen
Copy link
Contributor Author

@cchaos Just to check, do you still have any more change requests or do this look good to merge to you?

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@cee-chen cee-chen merged commit 3b8aa95 into elastic:main Mar 18, 2022
@cee-chen cee-chen deleted the datagrid/footer-fixes branch March 18, 2022 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants