Skip to content

Commit

Permalink
Merge pull request #12628 from erikhorlings/primeng-issue-12624
Browse files Browse the repository at this point in the history
Take into account that options can be grouped when validating input.
  • Loading branch information
cetincakiroglu authored Jun 16, 2023
2 parents 3313b1f + a9cce6f commit 7bcc5e7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,14 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr
let inputValue = target.value.trim();

if (this.suggestions) {
for (let suggestion of this.suggestions) {
let suggestions = [...this.suggestions];
if (this.group) {
let groupedSuggestions = this.suggestions.filter(s => s[this.optionGroupChildren])
.flatMap(s => s[this.optionGroupChildren]);
suggestions = suggestions.concat(groupedSuggestions);
}

for (let suggestion of suggestions) {
let itemValue = this.field ? ObjectUtils.resolveFieldData(suggestion, this.field) : suggestion;
if (itemValue && inputValue === itemValue.trim()) {
valid = true;
Expand Down

1 comment on commit 7bcc5e7

@vercel
Copy link

@vercel vercel bot commented on 7bcc5e7 Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.