UI: Fix reset button in AdvancedMultiSelect.js

Reset button will reset to all safe values
This commit is contained in:
vakarisz 2022-07-04 13:00:36 +03:00
parent ed46538137
commit 20f091ff4e
1 changed files with 4 additions and 13 deletions

View File

@ -93,8 +93,6 @@ class AdvancedMultiSelect extends React.Component {
onChildCheckboxClick = (value) => { onChildCheckboxClick = (value) => {
let selectValues = this.getSelectValuesAfterClick(value); let selectValues = this.getSelectValuesAfterClick(value);
this.onChange(selectValues); this.onChange(selectValues);
this.setHideResetState(selectValues);
} }
getSelectValuesAfterClick(clickedValue) { getSelectValuesAfterClick(clickedValue) {
@ -128,15 +126,7 @@ class AdvancedMultiSelect extends React.Component {
} }
onResetClick = () => { onResetClick = () => {
this.onChange(this.defaultValues); this.setPaneInfoToSafe();
this.setHideResetState(this.defaultValues);
this.setPaneInfoToSafe(this.isUnsafeOptionSelected(this.defaultValues));
}
setHideResetState(selectValues) {
this.setState(() => ({
hideReset: this.getHideResetState(selectValues)
}));
} }
getHideResetState(selectValues) { getHideResetState(selectValues) {
@ -168,9 +158,10 @@ class AdvancedMultiSelect extends React.Component {
); );
} }
setPaneInfoToSafe(isUnsafeOptionSelected) { setPaneInfoToSafe() {
let safePluginNames = this.state.allPluginNames.filter(pluginName => this.isSafe(pluginName)); let safePluginNames = this.state.allPluginNames.filter(pluginName => this.isSafe(pluginName));
this.setState({selectedPluginNames: safePluginNames}); this.setState({selectedPluginNames: safePluginNames});
this.onChange(safePluginNames);
} }
render() { render() {
@ -195,7 +186,7 @@ class AdvancedMultiSelect extends React.Component {
checkboxState={this.getMasterCheckboxState( checkboxState={this.getMasterCheckboxState(
this.state.selectedPluginNames)} this.state.selectedPluginNames)}
hideReset={this.getHideResetState( hideReset={this.getHideResetState(
this.state.allPluginNames)} this.state.selectedPluginNames)}
onResetClick={this.onResetClick}/> onResetClick={this.onResetClick}/>
<ChildCheckboxContainer id={id} multiple={multiple} required={required} <ChildCheckboxContainer id={id} multiple={multiple} required={required}