From 89a842232005db561ea135970242d0f76a7749b6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 7 Feb 2019 11:54:13 -0700 Subject: [PATCH] Ensure toggle switches listen to property changes 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 https://github.com/vector-im/riot-web/issues/8432 --- src/components/views/elements/ToggleSwitch.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/views/elements/ToggleSwitch.js b/src/components/views/elements/ToggleSwitch.js index 19c87aab56..0d8b3d042f 100644 --- a/src/components/views/elements/ToggleSwitch.js +++ b/src/components/views/elements/ToggleSwitch.js @@ -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();