У меня три переключателя с пользовательскими ролями.Когда я нажимаю на любую радио-кнопку, она не выбирается;переключатели выбираются только при двойном нажатии.
Я использую React с materialUI.
Ниже приведен мой код,
handleRoleChange(event) {
const newRole = event.target.value
const companiesAccess = isPlatformUserRole(newRole) ? 'ALL' : 'SELECT'
this.changeFormField('companiesAccess', companiesAccess)
this.changeFormField('companyTags', []) // clear current selection
}
<label className={style.requiredLabel} htmlFor="role">
<span>ROLE</span>
</label>
<Radio
display="row"
name="role"
radioItems={options.roleOptions}
handleClickOnRadio={this.handleRoleChange}
readOnly={!isNew}
/>
, где options.roleOptions
список ролей.
код для настраиваемой радиокнопки,
const Radio = (props) => {
let radioButtonStyle = props.display === 'column' ? radioStyleColumn : radioStyleRow
radioButtonStyle = { ...radioButtonStyle, ...props.radioButtonStyle }
const items = props.radioItems.map((item, index) => {
const disabled = _isUndefined(item.disabled) ? props.disabled : item.disabled
/* let checked = false
if (props.currentUser === item.value) {
checked = true
} else {
checked = false
}
console.log(props.currentUser+' '+item.value+' '+checked)
debugger;*/
return (<RadioButton
key={index}
value={item.value}
label={item.label}
disabled={disabled}
style={radioButtonStyle}
labelStyle={labelStyle}
iconStyle={iconStyle}
inputStyle={inputStyle}
checkedIcon={activeRadioIcon()}
uncheckedIcon={normalRadioIcon()}
onClick={props.handleClickOnRadio}
/>)
})
Заранее спасибо.