[DataGrid] Improve clarity of numeric filter operator labels
Replace numeric symbol operators with descriptive text labels. Improves the clarity of the operator options, and brings them inline with header filter labels.
Addresses point made here: https://github.com/mui/mui-x/pull/14489#discussion_r1746674067
- [x] I have followed (at least) the PR section of the contributing guide.
Localization writing tips :writing_hand:
Seems you are updating localization :earth_africa: files.
Thank you for contributing to the localization! :tada: To make your PR perfect, here is a list of elements to check: :heavy_check_mark:
- [ ] 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-14638--material-ui-x.netlify.app/
Generated by :no_entry_sign: dangerJS against c79b37f335747ce3490372fe5123f1ed57f61f9a
@romgrk to clarify, do you mean instead of updating filterOperator=, where the label is displayed, use the filerOperatorEquals translation key that already exists?
If that is what you mean, I tried it and found that the translation key is coupled to the value in gridNumericOperators.ts We transform the operator value here to create the translation key.
I don't particularly like this, it feels like magic and isn't type-safe. It would probably be better to have an extra key in the operator object for a translation key:
{
value: '=',
+ labelTranslationKey: 'filerOperatorEquals',
getApplyFilterFn: (filterItem) => {
if (filterItem.value == null || Number.isNaN(filterItem.value)) {
return null;
}
return (value): boolean => {
return parseNumericValue(value) === filterItem.value;
};
},
InputComponent: GridFilterInputValue,
InputComponentProps: { type: 'number' },
}
What do you think?
How about renaming the text labels to replace the operator labels? filterOperatorEquals -> filterOperator=
I just want to avoid having duplicate translations for the same text.
@romgrk I agree that we don't want duplicates.
filterOperatorEquals -> filterOperator=
We would have the same problem with this example.
We would have to update the equals string operator value to = to use the translation, but this would be a breaking change to the filter model. This would no longer work:
filterModel={{
items: [{ field: 'someString', operator: 'equals', value: 'some value' }],
^ it now expects `=`
}}
This pull request has conflicts, please resolve those before we can evaluate the pull request.