From 3902d8a107335027c56af49a3ec0ad08ceb1a1bf Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 14 Jul 2018 02:01:10 +0200 Subject: [PATCH] [FormControlLabel] Add a failing test case and fix it (#12141) --- .../src/FormControlLabel/FormControlLabel.js | 51 +++++++++---------- .../FormControlLabel/FormControlLabel.test.js | 18 +++++-- 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/packages/material-ui/src/FormControlLabel/FormControlLabel.js b/packages/material-ui/src/FormControlLabel/FormControlLabel.js index d5ef0bfddbaadc..c17b1a0f20de59 100644 --- a/packages/material-ui/src/FormControlLabel/FormControlLabel.js +++ b/packages/material-ui/src/FormControlLabel/FormControlLabel.js @@ -47,40 +47,37 @@ function FormControlLabel(props, context) { value, ...other } = props; - const { muiFormControl } = context; - let disabled = disabledProp; - if (typeof control.props.disabled !== 'undefined') { - if (typeof disabled === 'undefined') { - disabled = control.props.disabled; - } + let disabled = disabledProp; + if (typeof disabled === 'undefined' && typeof control.props.disabled !== 'undefined') { + disabled = control.props.disabled; } - - if (muiFormControl) { - if (typeof disabled === 'undefined') { - disabled = muiFormControl.disabled; - } + if (typeof disabled === 'undefined' && muiFormControl) { + disabled = muiFormControl.disabled; } - const className = classNames( - classes.root, - { - [classes.disabled]: disabled, - }, - classNameProp, - ); + const controlProps = { + disabled, + }; + ['checked', 'name', 'onChange', 'value', 'inputRef'].forEach(key => { + if (typeof control.props[key] === 'undefined' && typeof props[key] !== 'undefined') { + controlProps[key] = props[key]; + } + }); return ( -