Skip to content

Commit

Permalink
Merge pull request #1736 from creative-commoners/pulls/2.2/fix-sercha…
Browse files Browse the repository at this point in the history
…bledropdownfield

FIX SearchableDropdownField pass incorrect value on onChange event
  • Loading branch information
GuySartorelli committed May 13, 2024
2 parents 6925ecb + 038173c commit ca4d75b
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 ca4d75b

Please sign in to comment.