-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
[TypeScript] Fix FilterLiveSearchProps should extend TextInputProps #7859
Conversation
source?: string; | ||
sx?: SxProps; | ||
label?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should override the label prop as we forward it as is to the TextInput
. We only provide a default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would tend to agree with @septentrion-730n because his solution still provides a default value and also supports being overridden by the user directly in the FilterLiveSearch component.
Previously the only way you could customize the label was through localization.
However, it could be nice to handle translation on this field either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TextInput
already support all these use cases: https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/input/TextInput.tsx#L66 via FieldTitle
.
Btw, we don't event need to translate here, we could just pass the translation key directly as label
and it will be translated
const { | ||
source = 'q', | ||
variant, | ||
label = translate('ra.action.search'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't even need to translate here, just pass the translation key directly to the label
prop. <TextInput>
will handle the translation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, accepting react node for this label would complicate the code as we only use it as the TextInput
label when the variant
is outlined
. Otherwise, we pass it as the placeholder
prop
const { | ||
source = 'q', | ||
variant, | ||
label = translate('ra.action.search'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, accepting react node for this label would complicate the code as we only use it as the TextInput
label when the variant
is outlined
. Otherwise, we pass it as the placeholder
prop
Fixes #7832