Skip to content

Commit

Permalink
Merge pull request #14826 from rosenthalj/multiselectToggleAllFix_146…
Browse files Browse the repository at this point in the history
…03_14252_14807

fixed #14807 #14252 #14603 - updated onToggleAll method to call onChange and onSelectAllChange
  • Loading branch information
cetincakiroglu authored Feb 23, 2024
2 parents c785276 + 8cceb48 commit 0dfa2c0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/components/multiselect/multiselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,12 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
return this.config.getTranslation(TranslationKeys.ARIA)['listLabel'];
}

private getAllVisibleAndNonVisibleOptions() {
return this.group ? this.flatOptions(this.options) : this.options || [];
}

visibleOptions = computed(() => {
const options = this.group ? this.flatOptions(this.options) : this.options || [];
const options = this.getAllVisibleAndNonVisibleOptions();
const isArrayOfObjects = ObjectUtils.isArray(options) && ObjectUtils.isObject(options[0]);

if (this._filterValue()) {
Expand Down Expand Up @@ -1834,8 +1838,17 @@ export class MultiSelect implements OnInit, AfterViewInit, AfterContentInit, Aft
.map((option) => this.getOptionValue(option));

this.updateModel(value, event);

// because onToggleAll could have been called during filtering, this additional test needs to be performed before calling onSelectAllChange.emit
if (!value.length || value.length === this.getAllVisibleAndNonVisibleOptions().length) {
this.onSelectAllChange.emit({
originalEvent: event,
checked: !!value.length
});
}
}

this.onChange.emit({ originalEvent: event, value: this.value });
DomHandler.focus(this.headerCheckboxViewChild?.nativeElement);
this.headerCheckboxFocus = true;

Expand Down

0 comments on commit 0dfa2c0

Please sign in to comment.