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] Display selector / toolbar control enhancements #8080

Merged
merged 11 commits into from
Oct 23, 2024

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Oct 16, 2024

Summary

This PR adds 3 separate enhancements (listed with screenshots below). As always, I strongly recommend following along by commit, as I tried to split out several code refactors out to make following the actual new features easier.


Redesigned row height form controls (493e2e0)

Per @MichaelMarcialis's designs in #7835 (comment) (although these changes do not close the issue,

Single/Default Custom lineCount Auto fit

Completely custom control over rendering the display selector (92bc73e, 81b5e25) (closes #7951)

Consumers can now pass a toolbarVisibility.showDisplaySelector.customRender render prop/function that passes back the default density/row height/reset button as optional nodes to render. This allows consumers to reorder and otherwise completely customize the display selector.

const customDisplaySelectorRender = ({ densityControl }) => (
  <div>Custom display selector {densityControl}</div>
);

<EuiDataGrid
  // ... required props
  toolbarVisibility={{
    showDisplaySelector: {
      customRender: customDisplaySelectorRender
    }
  }}
/>

gridStyle updates after users have changed grid styles via the display selector (9cf4a4d) (closes #7962)

Previously, EuiDataGrid would always defer to the user's row height/density selection from the display selector controls, and if consumers tried to pass in new gridStyle updates after, or control them from an external button, those updates would be ignored.

You can reproduce this on production by changing the density in the toolbar display selector and then trying to change fontSize or cellPadding in the Storybook controls - nothing happens at that point.

This PR changes this behavior so that new gridStyle updates are reflected in the datagrid (see QA steps below).

QA

General checklist

  • Browser QA
    - [ ] Checked in both light and dark modes
    - [ ] Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
    - [ ] Added documentation
    • Props have proper autodocs (using @default if default values are missing) and playground toggles
      - [ ] Checked Code Sandbox works for any docs examples
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
      - [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist
    • If applicable, file an issue to update EUI's Figma library with any corresponding UI changes. (This is an internal repo, if you are external to Elastic, ask a maintainer to submit this request)

…n subcomponents

- we'll need this in order to pass it back a render prop version of this popover

- also feels much cleaner code wise! and lets us not render some extra state if controls have been configured to be off
+ remove unnecessary flex item wrapper

+ reorder buttonLabel to be closer to displaySelector
- not flagging it in the main docs as it doesn't seem important enough, let me know if you disagree

- it is in the snippets and props examples however

+ fix bad indentation and syntax on some existing snippets
…have been made

- requires updating how reset button behaves, and storing initial display settings in refs on mount

+ reorder/organize code with comment blocks / by concern

- modify deep equal to potentially not cost as much / re-run isEqual as often if the object *is* correctly memoized
- works when run alone, not entirely sure what's going on here
@cee-chen cee-chen marked this pull request as ready for review October 17, 2024 16:50
@cee-chen cee-chen requested a review from a team as a code owner October 17, 2024 16:50
- indentation nit

- fix object equality issue when rowHeightsOptions is initialized with `{ lineCount }`
Copy link
Contributor

@mgadewoll mgadewoll left a comment

Choose a reason for hiding this comment

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

🚢 🐈‍⬛ Those are awesome improvements! The fixes/updates work as expected and the code looks good to me. 👍
I left two small recommendations but they're not blocking.

@@ -67,8 +70,68 @@ const convertGridStylesToSelection = (gridStyles: EuiDataGridStyle) => {
return 'expanded';
return '';
};
const DensityControl = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering this file is quite large and since we're creating standalone parts now anyway maybe we could move those sub components to their own files? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is definitely subjective / more of an art than a science, but to me in its current state the file would be more annoying to have it broken up than in one (slightly larger) file since I'd have to be referring back and forth to separate files to see how it all works together, particularly with the reset button.

My 2c is that it's not egregious right now since it's still below ~500 lines (especially considering comments etc) and concerns one major UI element (the display settings popover and its contents).

@cee-chen cee-chen enabled auto-merge (squash) October 23, 2024 15:47
@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@cee-chen cee-chen merged commit 07a6a6f into elastic:main Oct 23, 2024
5 checks passed
@cee-chen cee-chen deleted the datagrid/display-selector branch October 23, 2024 16:30
cee-chen added a commit to elastic/kibana that referenced this pull request Oct 31, 2024
`v97.2.0`⏩`v97.3.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v97.3.0`](https://github.com/elastic/eui/releases/v97.3.0)

- `EuiDataGrid` now supports a new
`toolbarVisibility.showDisplaySelector.customRender` function that
allows completely customizing the rendering of the display selector
popover ([#8080](elastic/eui#8080))
- `EuiDataGrid`'s row height/lines per row setting has been streamlined
in both UI and UX ([#8080](elastic/eui#8080))
- `EuiDataGrid` now accepts consumer-passed display setting updates even
after users have changed their display preferences via UI
([#8080](elastic/eui#8080))
- Updated `EuiDataGrid` to vertically center all
`toolbarVisibility.additionalControls` nodes
([#8085](elastic/eui#8085))
- Updated `EuiDataGrid` with a beta
`rowHeightsOptions.autoBelowLineCount` feature flag
([#8096](elastic/eui#8096))
- Updated `EuiContextMenuPanel` to allow disabling initial focus via
`initialFocusedItemIndex={-1}`
([#8101](elastic/eui#8101))

**Bug fixes**

- Fixed `EuiComment`'s typing to correctly reflect all accepted props
([#8089](elastic/eui#8089))
- Fixed `EuiSelectableTemplateSitewide`s within dark-themed `EuiHeader`s
missing input borders
([#8100](elastic/eui#8100))
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 31, 2024
`v97.2.0`⏩`v97.3.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v97.3.0`](https://github.com/elastic/eui/releases/v97.3.0)

- `EuiDataGrid` now supports a new
`toolbarVisibility.showDisplaySelector.customRender` function that
allows completely customizing the rendering of the display selector
popover ([elastic#8080](elastic/eui#8080))
- `EuiDataGrid`'s row height/lines per row setting has been streamlined
in both UI and UX ([elastic#8080](elastic/eui#8080))
- `EuiDataGrid` now accepts consumer-passed display setting updates even
after users have changed their display preferences via UI
([elastic#8080](elastic/eui#8080))
- Updated `EuiDataGrid` to vertically center all
`toolbarVisibility.additionalControls` nodes
([elastic#8085](elastic/eui#8085))
- Updated `EuiDataGrid` with a beta
`rowHeightsOptions.autoBelowLineCount` feature flag
([elastic#8096](elastic/eui#8096))
- Updated `EuiContextMenuPanel` to allow disabling initial focus via
`initialFocusedItemIndex={-1}`
([elastic#8101](elastic/eui#8101))

**Bug fixes**

- Fixed `EuiComment`'s typing to correctly reflect all accepted props
([elastic#8089](elastic/eui#8089))
- Fixed `EuiSelectableTemplateSitewide`s within dark-themed `EuiHeader`s
missing input borders
([elastic#8100](elastic/eui#8100))

(cherry picked from commit 4e7d43a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants