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

NumberInput does not support min and max props or incorrect documentation #4900

Closed
lucapiazzoni opened this issue Jun 5, 2020 · 3 comments · Fixed by #4912
Closed

NumberInput does not support min and max props or incorrect documentation #4900

lucapiazzoni opened this issue Jun 5, 2020 · 3 comments · Fixed by #4912
Assignees
Labels

Comments

@lucapiazzoni
Copy link

What you were expecting:
I expected that the NumberInput component supports min and max props as specified in the documentation.

What happened instead:
It seems that the input does not prevent the user to input an out of range value.

Related code:
I added the code needed to reproduce the issue in that codesandbox.
You can find the component inside post's Miscellaneus section (field "Average Note")
https://codesandbox.io/s/misty-frog-2u2vu

https://codesandbox.io/s/misty-frog-2u2vu?file=/src/posts/PostEdit.js (line 125)
<NumberInput source="average_note" max="5" min="1" step="0.5" />

Other information:
It can be a misunderstanding reading the documentation, or maybe it is better to add some usage examples.

@kopax
Copy link
Contributor

kopax commented Jun 6, 2020

For this, I use validate props and utils.

@fzaninotto
Copy link
Member

Confirmed, this is a material-ui bug (see mui/material-ui#11377) that we can hide in react-admin.

@fzaninotto fzaninotto added the bug label Jun 8, 2020
@fzaninotto
Copy link
Member

fzaninotto commented Jun 8, 2020

However, this will only affect the arrows - users will still be able to enter a numeric value higher than the max ans lower than the min. You should add a validate function, as explained by @kopax .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants