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

[DataGrid] Header filter design improvements #15991

Merged
merged 25 commits into from
Jan 16, 2025

Conversation

KenanYusuf
Copy link
Member

@KenanYusuf KenanYusuf commented Dec 23, 2024

Closes #15486

https://deploy-preview-15991--material-ui-x.netlify.app/x/react-data-grid/filtering/header-filters/

Changelog

Breaking changes

  • The clear button in header filter cells has moved to the header filter menu. Use slotProps={{ headerFilterCell: { showClearIcon: true } }} to restore the clear button in the cell.

@KenanYusuf KenanYusuf added breaking change component: data grid This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer v8.x labels Dec 23, 2024
@mui-bot
Copy link

mui-bot commented Dec 23, 2024

Localization writing tips ✍️

Seems you are updating localization 🌍 files.

Thank you for contributing to the localization! 🎉 To make your PR perfect, here is a list of elements to check: ✔️

  • Verify if the PR title respects the release format. Here are two examples (depending if you update or add a locale file)

    [l10n] Improve Swedish (sv-SE) locale
    [l10n] Add Danish (da-DK) locale

  • Update the documentation of supported locales by running pnpm l10n
  • Clean files with pnpm prettier.

Deploy preview: https://deploy-preview-15991--material-ui-x.netlify.app/

Updated pages:

Generated by 🚫 dangerJS against d96b3c6

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 24, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@KenanYusuf KenanYusuf marked this pull request as ready for review December 24, 2024 15:41
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 24, 2024
@KenanYusuf KenanYusuf requested a review from a team December 24, 2024 16:25
Copy link
Member

Choose a reason for hiding this comment

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

It'd be great to keep the keyboard navigation working in the menu.

Current behavior Updated behavior (this PR)
master.mp4
current.mp4

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for fixing it, looks much better.

Another small thing that I noticed is around the singleSelect and boolean fields. When you use Return to enable the editing state on such a column, pressing Return again opens the select options, but even after closing it, the focus keeps on the dropdown and the keyboard navigation doesn't allow to go to next cell (unless Esc is pressed)

keyboard-nav-hf.mp4

How about moving the focus back to the cell when a value is set (second Return is pressed)?

Copy link
Member Author

@KenanYusuf KenanYusuf Jan 8, 2025

Choose a reason for hiding this comment

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

Fair point... I'm thinking we should leave this behavior as it is, given Return is the primary way to interact with a select field via keyboard 🤔

At least this way, users have the option to change the value again with Return, or leave the field with Esc.

Copy link
Member

@MBilalShafi MBilalShafi Jan 13, 2025

Choose a reason for hiding this comment

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

At least this way, users have the option to change the value again with Return, or leave the field with Esc.

I understand your point, although it is a trivial thing but just to relate the keyboard navigation for other field types, consider a scenario.

Press Return (edit state activated) -> Update value -> Press Return (edit state deactivated) -> Use navigation keys to focus next cell. (So this user might not be used to pressing Esc during updating multiple filter cells)

The select and boolean would deviate from this pattern and the user might get confused if they can deactivate edit state on some fields with Return + Esc but on some with Esc only. Plus some users might assume the Esc would revert the changes in addition to deactivating the edit state.

(Not necessarily with this PR but) If we dive deep on this, we could settle on a single pattern for all the field types. I'd go with:

  1. Activate edit state: Return
  2. Deactivate edit state: Return
  3. Deactivate edit state and revert changes: Esc

This would also align with the editing behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think it would make sense to explore it further and unify the keyboard navigation behaviour. Added an issue for future #16206

@KenanYusuf KenanYusuf requested a review from MBilalShafi January 3, 2025 09:47
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 3, 2025
Copy link

github-actions bot commented Jan 3, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 3, 2025
Copy link
Member

@MBilalShafi MBilalShafi left a comment

Choose a reason for hiding this comment

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

Really nice design update. 👏 Thank you @KenanYusuf for working on it.

Added a few minor comments, apart from them it LGTM.

docs/data/data-grid/filtering/header-filters.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for fixing it, looks much better.

Another small thing that I noticed is around the singleSelect and boolean fields. When you use Return to enable the editing state on such a column, pressing Return again opens the select options, but even after closing it, the focus keeps on the dropdown and the keyboard navigation doesn't allow to go to next cell (unless Esc is pressed)

keyboard-nav-hf.mp4

How about moving the focus back to the cell when a value is set (second Return is pressed)?

Copy link
Member

Choose a reason for hiding this comment

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

An indication (e.g. greying out of input using disabled prop) of non-text filters (like isEmpty) would be great.
Currently we have a dotted line to indicate that.

This PR:

image

Current (mui.com/x/):

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Using an input at all for a filter that doesn't require input isn't good UX imo.

Copy link
Member Author

@KenanYusuf KenanYusuf Jan 14, 2025

Choose a reason for hiding this comment

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

Agree. Before fixing the disabled state, I explored just displaying the active filter label in the field:

Screenshot 2025-01-14 at 08 20 47

I don't think it looks great, but it's probably better than displaying an empty disabled input. What do we think?

Copy link
Contributor

@romgrk romgrk Jan 14, 2025

Choose a reason for hiding this comment

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

Imho it's good enough. Maybe I'd explore displaying it as a badge/chip, maybe with a remove button:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

I've gone with the plain text label as I think it works better with the existing close button and alongside the outlined inputs in other columns. Will revisit this again when I have more time to look at filter design.

@@ -24,6 +24,12 @@ You can disable the default filter panel using `disableColumnFilter` prop and on

{{"demo": "SimpleHeaderFilteringDataGridPro.js", "bg": "inline", "defaultCodeOpen": false}}

## Inline clear button
Copy link
Member

Choose a reason for hiding this comment

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

Would this make more sense under Customize header filter section since it's kind-of a customization?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is, but it's also very similar to the "Simple header filters" section above 😅 Could move both?

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged and removed PR: out-of-date The pull request has merge conflicts and can't be merged labels Jan 14, 2025
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 16, 2025
@KenanYusuf KenanYusuf merged commit f8510a4 into mui:master Jan 16, 2025
18 checks passed
@KenanYusuf KenanYusuf deleted the header-filter-design branch January 16, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: data grid This is the name of the generic UI component, not the React module! design This is about UI or UX design, please involve a designer v8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Change default TextField variant
4 participants