-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Description
Describe the bug
When setting a function for the onChange prop it never get's called with invalid values. If the user enters an invalid value the fallback value is used. From the outside there is no way to know if the user entered an invalid value and e.g. show an error message instead of submitting the fallback value.
To Reproduce
(Non)Pseudocode to reproduce
const MyComponent = () => {
const [color, setColor] = React.useState('#ffffff')
let error = ''
const handleChange = (color) => {
if(!matchIsValidColor(color)) {
error = 'Invalid color!'
return
}
setColor(color)
}
return (
<MuiColorInput value={color} onChange={handleChange} />
)
Expected behavior
If the user enters an invalid value error gets set to 'Invalid color'.
Actual behavior
error never gets set to 'Invalid color'
Desktop (please complete the following information):
- OS: MacOS Sonoma
- Browser: Edge
- Version: 125.0.2535.79
Metadata
Metadata
Assignees
Labels
No labels