Skip to content

Commit

Permalink
FIX SearchableDropdownField pass incorrect value on onChange event
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed May 7, 2024
1 parent 3434873 commit 038173c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const SearchableDropdownField = ({
setHasChanges(true);
setJustChanged(true);
}
onChange(val);
if (multi) {
onChange(val);
} else {
onChange(val, { value: val.value });
}
};

/**
Expand Down Expand Up @@ -121,6 +125,16 @@ const SearchableDropdownField = ({
const refProps = passRef ? { ref: selectComponentRef } : {};

let val = value;

if (typeof val !== 'object' && (options && options.length > 0)) {
options.forEach(option => {
// eslint-disable-next-line eqeqeq
if (option.value == value) {
val = option;
}
});
}

// For non-multi only the first value is needed
if (!multi && val) {
const keys = Object.keys(val);
Expand Down

0 comments on commit 038173c

Please sign in to comment.