Skip to content

Commit

Permalink
Multiselect | Refactor on label
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Nov 1, 2023
1 parent 34f648b commit fe9e52a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,6 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
} else {
label = this.placeholder || this.defaultLabel || '';
}

return label;
});

Expand Down Expand Up @@ -1284,7 +1283,7 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
}

isOptionGroup(option) {
return this.optionGroupLabel && option.optionGroup && option.group;
return (this.group || this.optionGroupLabel) && option.optionGroup && option.group;
}

isValidOption(option) {
Expand Down Expand Up @@ -1330,9 +1329,8 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
}

getLabelByValue(value) {
const options = this.optionGroupLabel ? this.flatOptions(this._options()) : this._options() || [];
const options = this.group ? this.flatOptions(this._options()) : this._options() || [];
const matchedOption = options.find((option) => !this.isOptionGroup(option) && ObjectUtils.equals(this.getOptionValue(option), value, this.equalityKey()));

return matchedOption ? this.getOptionLabel(matchedOption) : null;
}

Expand Down

1 comment on commit fe9e52a

@vercel
Copy link

@vercel vercel bot commented on fe9e52a Nov 1, 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.