Skip to content

Commit

Permalink
Merge pull request #1786 from creative-commoners/pulls/2.2/elemental-…
Browse files Browse the repository at this point in the history
…dropdown

FIX Use correct argument for FormBuilder context
  • Loading branch information
GuySartorelli authored Jun 21, 2024
2 parents 2730ef7 + a11d448 commit 09ebc84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions client/src/components/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ class Search extends Component {
const value = formData[key];
if (value) {
data[key] = value;
// For has_one relations an autoscaffoled SearchableDropdownField will be used that itself
// uses a react-select field which uses objects as values. We need to extract the value
if (key.substring(key.length - 2) === 'ID'
&& typeof value === 'object'
&& value.hasOwnProperty('value')
) {
data[key] = value.value;
}
}
});

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

/**
Expand Down Expand Up @@ -126,15 +122,6 @@ const SearchableDropdownField = ({

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 09ebc84

Please sign in to comment.