[SwitchBase] Ignores FormControl disabled state
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
When the [FormControl] component is rendered with the disabled={true}
prop, the children [Checkbox], [Radio], and [Switch] components remains enabled
Expected Behavior 🤔
All the children components of [FormControl] that use [FormControlContext] should be disabled if the [FormControl] components is disabled
Steps to Reproduce 🕹
This sandbox demonstrates the issue that appeared from v4.6.1 due to this pull request.
This sandbox clearly shows that everything was working correctly in v4.6.0
Context 🔦
The [SwitchBase] component checks whether it has own disabled
prop. If it doesn’t have it, the disabled
from [FormControlContext] is used (please see source code)
The issue is that the [Checkbox], [Radio], and [Switch] components were configured to use the disabled
prop set to false
by default (please see checkbox, radio, and switch changes).
Therefore, the [SwitchBase] component never receives the disabled={undefined}
prop, which leads to non-usage of the disabled
value from [FormControlContext]
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | v4.8.3 |
React | v16.12.0 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
IIRC, it should be possible to add it to each component’s
propValues
in framerConfig.js. Adding it to the component directly was intended to fix the problem “at source”, while also allowing the default to be documented in the prop docs; but clearly it backfired in this instance!If you don’t mind, I’ll take it over