Controlled Checkbox and Switch do not set the checked
property on the underlying input component correctly.
#27963
Closed
2 tasks done
Labels
component: checkbox
This is the name of the generic UI component, not the React module!
status: expected behavior
Does not imply the behavior is intended. Just that we know about it and can't work around it
Current Behavior 😯
When rendering a controlled
Checkbox
orSwitch
component like so:The underlying input component will the same value for
checked
regardless ofisChecked
is true or not.Expected Behavior 🤔
These components:
Should respectively have these underlying input components:
Note that this is also the case for
Switch
Steps to Reproduce 🕹
https://codesandbox.io/s/nifty-snyder-pdwsx
Steps:
checked
value doesn't change while theinputProps
attributes do.Context 🔦
This makes running
expect(screen.getByLabelText("test label")).toBeChecked()
impossible, which goes against the material-ui testing recommendations: https://next.material-ui.com/guides/testing/#userspaceYour Environment 🌎
`npx @material-ui/envinfo`
The text was updated successfully, but these errors were encountered: