-
-
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
Fixed number input label issue #6361
Fixed number input label issue #6361
Conversation
/> | ||
label !== '' && | ||
label !== false && ( | ||
<FieldTitle |
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.
It would probably be better to handle this in FieldTitle
directly. Then we would only have to update the propTypes in all the other components
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.
Handled label issue directly inside FieldTitle
. Updated propType for NumberInput field.
I will raise separate PR to update label propType in other components. Will it be fine?
Let me know if any changes required.
Thanks..!
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.
Please update the propTypes and TypeScript types in this PR
Thanks! |
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.
Thanks for your PR.
You should also refactor TextInput, SelectInput and RichTextInput to remove the test on label !== false
, which is now redundant.
You should document that feature in the Input documentation.
Finally, this is technically a new feature, and as such it should be PRed against next
rather than master
.
@@ -18,9 +18,15 @@ export const FieldTitle: FunctionComponent<Props> = ({ | |||
isRequired, | |||
}) => { | |||
const translate = useTranslate(); | |||
|
|||
if (label === false && label === '') { |
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.
this doesn't make sense
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.
Ok. So the desired behavior is to return null only if label is false. Right? Correct me if I am wrong.
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 just followed below existing code -
https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/input/TextInput.tsx#L65
As per this code, FieldTitle
will not get rendered if string is empty.
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.
my bad, you're right. Both ''
and false
should disable the title.
expect(container.firstChild).toBeNull(); | ||
}); | ||
|
||
it('should return null if label is empty 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.
This isn't the desired behavior. An empty string should lead to an empty label (not the absence of label)
|
Closes #6352
Fixed label issue for Number input.
Before - with
label={false}