From 793bb99309011bef23148090f1a49a4c37c38bfe Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 5 Mar 2021 12:32:34 -0500 Subject: [PATCH 1/2] ui: properly render master checkbox on import or reset Fixes #1018 --- .../components/ui-components/AdvancedMultiSelect.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js index 8503a74fc..a8878c986 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js @@ -94,9 +94,11 @@ class AdvancedMultiSelect extends React.Component { } setMasterCheckboxState(selectValues) { - this.setState(() => ({ - masterCheckboxState: this.getMasterCheckboxState(selectValues) - })); + let newState = this.getMasterCheckboxState(selectValues); + + if (newState != this.state.masterCheckboxState) { + this.setState({masterCheckboxState: newState}); + } } getMasterCheckboxState(selectValues) { @@ -188,6 +190,10 @@ class AdvancedMultiSelect extends React.Component { ); } + + componentDidUpdate(_prevProps) { + this.setMasterCheckboxState(this.props.value); + } } export default AdvancedMultiSelect; From 5e21ff88cb6f8f2b74e0f52a521eb113f2168a38 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 5 Mar 2021 12:32:57 -0500 Subject: [PATCH 2/2] ui: minor style changes in AdvancedMultiSelect --- .../components/ui-components/AdvancedMultiSelect.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js index a8878c986..193cb40b0 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/AdvancedMultiSelect.js @@ -43,7 +43,7 @@ class AdvancedMultiSelect extends React.Component { infoPaneParams: getDefaultPaneParams( this.infoPaneRefString, this.registry, - this.isUnsafeOptionSelected(this.props.value) + this.isUnsafeOptionSelected(props.value) ) }; } @@ -164,11 +164,12 @@ class AdvancedMultiSelect extends React.Component { render() { const { - schema, + autofocus, id, - required, multiple, - autofocus + required, + schema, + value } = this.props; return ( @@ -181,7 +182,7 @@ class AdvancedMultiSelect extends React.Component { + selectedValues={value} enumOptions={this.enumOptions}/>