Skip to content

Commit

Permalink
fix(CODE): ADDON-47714 Fixed dependent field reset issue (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbalar-splunk authored Oct 31, 2022
1 parent 1dd963d commit 51d9f58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ui/src/main/webapp/components/BaseFormView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ class BaseFormView extends PureComponent {
if (required && !currentValue) {
load = false;
data[dependency] = null;
} else if (currentValue === 'RESET_VALUE') {
load = true;
} else {
data[dependency] = currentValue;
}
Expand Down
6 changes: 4 additions & 2 deletions ui/src/main/webapp/components/SingleInputComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function SingleInputComponent(props) {
if (dependencyValues) {
options.params = { ...options.params, ...dependencyValues };
}
if (!dependencies || dependencyValues) {
if (!dependencies || (dependencyValues && Object.keys(dependencyValues).length)) {
setLoading(true);
axiosCallWrapper(options)
.then((response) => {
Expand All @@ -107,6 +107,8 @@ function SingleInputComponent(props) {
setLoading(false);
}
});
} else {
setOptions(null);
}
// eslint-disable-next-line consistent-return
return () => {
Expand Down Expand Up @@ -158,7 +160,7 @@ function SingleInputComponent(props) {
data-test="clear"
appearance="secondary"
icon={<Clear />}
onClick={() => restProps.handleChange(field, '')}
onClick={() => restProps.handleChange(field, 'RESET_VALUE')}
/>
) : null}
</>
Expand Down

0 comments on commit 51d9f58

Please sign in to comment.