Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Ensure toggle switches listen to property changes
Browse files Browse the repository at this point in the history
They do local echo on changes to avoid jumping back and forth while requests are ongoing, however some areas modify the checked state after the toggle has mounted.

Fixes element-hq/element-web#8432
  • Loading branch information
turt2live committed Feb 7, 2019
1 parent b50bfa1 commit 89a8422
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/views/elements/ToggleSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export default class ToggleSwitch extends React.Component {
};
}

componentWillReceiveProps(nextProps) {
if (nextProps.checked !== this.state.checked) {
this.setState({checked: nextProps.checked});
}
}

_onClick = (e) => {
e.stopPropagation();
e.preventDefault();
Expand Down

0 comments on commit 89a8422

Please sign in to comment.