From 0cdc242cfdbc01d2dfb7315534e7ab34a5559beb Mon Sep 17 00:00:00 2001 From: enahum Date: Mon, 4 Jul 2016 06:59:07 -0400 Subject: PLT-3444 Preview features checkboxes don't reset after hitting cancel (#3462) --- webapp/components/user_settings/user_settings_advanced.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'webapp') diff --git a/webapp/components/user_settings/user_settings_advanced.jsx b/webapp/components/user_settings/user_settings_advanced.jsx index 37a7a894f..cc5d2ee6d 100644 --- a/webapp/components/user_settings/user_settings_advanced.jsx +++ b/webapp/components/user_settings/user_settings_advanced.jsx @@ -20,6 +20,7 @@ export default class AdvancedSettingsDisplay extends React.Component { constructor(props) { super(props); + this.getStateFromStores = this.getStateFromStores.bind(this); this.updateSection = this.updateSection.bind(this); this.updateSetting = this.updateSetting.bind(this); this.toggleFeature = this.toggleFeature.bind(this); @@ -27,6 +28,10 @@ export default class AdvancedSettingsDisplay extends React.Component { this.renderFormattingSection = this.renderFormattingSection.bind(this); + this.state = this.getStateFromStores(); + } + + getStateFromStores() { const preReleaseFeaturesKeys = Object.keys(PreReleaseFeatures); const advancedSettings = PreferenceStore.getCategory(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS); const settings = { @@ -57,7 +62,11 @@ export default class AdvancedSettingsDisplay extends React.Component { } } - this.state = {preReleaseFeatures: PreReleaseFeatures, settings, preReleaseFeaturesKeys, enabledFeatures}; + return {preReleaseFeatures: PreReleaseFeatures, + settings, + preReleaseFeaturesKeys, + enabledFeatures + }; } updateSetting(setting, value) { @@ -118,6 +127,9 @@ export default class AdvancedSettingsDisplay extends React.Component { updateSection(section) { $('.settings-modal .modal-body').scrollTop(0).perfectScrollbar('update'); + if (!section) { + this.setState(this.getStateFromStores()); + } this.props.updateSection(section); } -- cgit v1.2.3-1-g7c22