Merge pull request #3541 from matrix-org/t3chguy/fix_150rc1
SettingsFlag always run ToggleSwitch fully-controlled
This commit is contained in:
commit
7160922b77
1 changed files with 3 additions and 11 deletions
|
@ -30,7 +30,6 @@ module.exports = createReactClass({
|
|||
label: PropTypes.string, // untranslated
|
||||
onChange: PropTypes.func,
|
||||
isExplicit: PropTypes.bool,
|
||||
manualSave: PropTypes.bool,
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
|
@ -47,8 +46,8 @@ module.exports = createReactClass({
|
|||
onChange: function(checked) {
|
||||
if (this.props.group && !checked) return;
|
||||
|
||||
if (!this.props.manualSave) this.save(checked);
|
||||
else this.setState({ value: checked });
|
||||
this.save(checked);
|
||||
this.setState({ value: checked });
|
||||
if (this.props.onChange) this.props.onChange(checked);
|
||||
},
|
||||
|
||||
|
@ -62,13 +61,6 @@ module.exports = createReactClass({
|
|||
},
|
||||
|
||||
render: function() {
|
||||
const value = this.props.manualSave ? this.state.value : SettingsStore.getValueAt(
|
||||
this.props.level,
|
||||
this.props.name,
|
||||
this.props.roomId,
|
||||
this.props.isExplicit,
|
||||
);
|
||||
|
||||
const canChange = SettingsStore.canSetValue(this.props.name, this.props.roomId, this.props.level);
|
||||
|
||||
let label = this.props.label;
|
||||
|
@ -78,7 +70,7 @@ module.exports = createReactClass({
|
|||
return (
|
||||
<div className="mx_SettingsFlag">
|
||||
<span className="mx_SettingsFlag_label">{label}</span>
|
||||
<ToggleSwitch checked={value} onChange={this.onChange} disabled={!canChange} aria-label={label} />
|
||||
<ToggleSwitch checked={this.state.value} onChange={this.onChange} disabled={!canChange} aria-label={label} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue