Skip to content

Commit

Permalink
Fix #7163: Refactor AutoComplete.js to fix the group selection (#7164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rekl0w authored Sep 12, 2024
1 parent 2648933 commit 1425a6c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions components/lib/autocomplete/AutoComplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,16 @@ export const AutoComplete = React.memo(
return;
}

const inputValue = ObjectUtils.trim(event.target.value);
const item = (props.suggestions || []).find((it) => {
const inputValue = ObjectUtils.trim(event.target.value).toLowerCase();
const allItems = (props.suggestions || []).flatMap((group) => {
return group.items ? group.items : [group];
});

const item = allItems.find((it) => {
const value = props.field ? ObjectUtils.resolveFieldData(it, props.field) : it;
const trimmedValue = value ? ObjectUtils.trim(value).toLowerCase() : '';

return value && inputValue === ObjectUtils.trim(value);
return trimmedValue && inputValue === trimmedValue;
});

if (item) {
Expand Down

0 comments on commit 1425a6c

Please sign in to comment.