Skip to content

Commit

Permalink
fix(CODE): ADDON-58867 Fixed cancelling selected dropdown value (#188)
Browse files Browse the repository at this point in the history
Co-authored-by: Tushar Balar <tbalar@splunk.com>
  • Loading branch information
artemrys and tbalar-splunk authored Dec 8, 2022
1 parent f3e09b1 commit 0144432
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions ui/src/main/webapp/components/BaseFormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ class BaseFormView extends PureComponent {
if (required && !currentValue) {
load = false;
data[dependency] = null;
} else if (currentValue === 'RESET_VALUE') {
} else if (currentValue === 'RESET_DROPDOWN_VALUE') {
load = true;
} else {
data[dependency] = currentValue;
Expand All @@ -713,7 +713,10 @@ class BaseFormView extends PureComponent {
}
});
}
changes[field] = { value: { $set: targetValue } };

// This is the custom logic to handle the dropdown's reset value, and we are setting null value
const target_value = targetValue === 'RESET_DROPDOWN_VALUE' ? null : targetValue;
changes[field] = { value: { $set: target_value } };

const newFields = update(this.state, { data: changes });
const tempState = this.clearAllErrorMsg(newFields);
Expand All @@ -722,7 +725,7 @@ class BaseFormView extends PureComponent {
if (this.hookDeferred) {
this.hookDeferred.then(() => {
if (typeof this.hook.onChange === 'function') {
this.hook.onChange(field, targetValue, tempState);
this.hook.onChange(field, target_value, tempState);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main/webapp/components/SingleInputComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function SingleInputComponent(props) {
data-test="clear"
appearance="secondary"
icon={<Clear />}
onClick={() => restProps.handleChange(field, 'RESET_VALUE')}
onClick={() => restProps.handleChange(field, 'RESET_DROPDOWN_VALUE')}
/>
) : null}
</>
Expand Down

0 comments on commit 0144432

Please sign in to comment.