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] Add "does not equal" and "does not contain" filter operators #14489

Merged

Conversation

KenanYusuf
Copy link
Contributor

@KenanYusuf KenanYusuf commented Sep 4, 2024

Adds "does not equal" and "does not contain" filter operators.

Some UX benchmarking was done to see whether there should be a separate negation modifier for the "does not" filters. In this case, it made sense to follow the filtering experience of similar tools and list the "does not" filters in the same field. See Figma.

Fixes #13300

@KenanYusuf KenanYusuf added component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature labels Sep 4, 2024
@KenanYusuf KenanYusuf marked this pull request as ready for review September 4, 2024 12:33
@mui-bot
Copy link

mui-bot commented Sep 4, 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-14489--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against a1e27b8

@KenanYusuf KenanYusuf requested a review from a team September 4, 2024 12:48
Copy link
Member

Choose a reason for hiding this comment

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

Should we increase the width of the operator dropdown? There's no way for the users to resize it so the UX could be a little bit disturbing with the new operators.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made that change a1e27b8

This is likely an issue for some translated operator labels too, but not sure of the best way to account for those right now.

Copy link
Member

Choose a reason for hiding this comment

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

This is likely an issue for some translated operator labels too, but not sure of the best way to account for those right now.

Agreed, I think we should be mindful of this when finalizing the new filter panel design.

Copy link
Member

Choose a reason for hiding this comment

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

Off-topic, but should we add string labels in place of numeric symbols?
image

= => Equals
!= => Not equals
and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think so.

It would also match what we have in header filters:

Screenshot 2024-09-06 at 11 28 37

I will create a follow up PR 👍

@KenanYusuf KenanYusuf merged commit f9e4b84 into mui:master Sep 9, 2024
18 checks passed
@KenanYusuf KenanYusuf deleted the not-contain-not-equal-filter-operators branch September 9, 2024 08:10
Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

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

Great!
Thanks for doing the benchmarks, it looks like having explicit filter operators for negations is a better option for an average user 👍🏻

const filterRegex = new RegExp(escapeRegExp(filterItemValue), 'i');
return (value): boolean => {
return value != null ? !filterRegex.test(String(value)) : true;
};
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to extract a function that will handle both contains and doesNotContain operators since the only difference is the opposite return value.
Same for the other two negated operators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense - will create a follow up PR for this improvement 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[data grid] add a "does not contain" filter
4 participants