Skip to content

Commit

Permalink
Fix a bug where redirect to the report page would cause selection box…
Browse files Browse the repository at this point in the history
…es to misrepresent current filters
  • Loading branch information
sei-bstein committed Feb 14, 2025
1 parent 288be7e commit 269b5d1
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, Component, Input, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { AfterViewInit, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, TemplateRef, ViewChild } from '@angular/core';
import { Subscription } from 'rxjs';
import { CustomInputComponent, createCustomInputControlValueAccessor } from '../custom-input/custom-input.component';
import { fa } from "@/services/font-awesome.service";
Expand All @@ -12,7 +12,7 @@ import { MultiSelectQueryParamModel } from '@/core/models/multi-select-query-par
styleUrls: ['./multi-select.component.scss'],
providers: [createCustomInputControlValueAccessor(MultiSelectComponent)]
})
export class MultiSelectComponent<TItem> extends CustomInputComponent<MultiSelectQueryParamModel<TItem>> implements OnInit, AfterViewInit, OnDestroy {
export class MultiSelectComponent<TItem> extends CustomInputComponent<MultiSelectQueryParamModel<TItem>> implements OnInit, OnChanges, AfterViewInit, OnDestroy {
@Input() label?: string;
@Input() searchPlaceholder?: string = "Search items";
@Input() options: TItem[] | null = [];
Expand Down Expand Up @@ -48,6 +48,12 @@ export class MultiSelectComponent<TItem> extends CustomInputComponent<MultiSelec
this._ngModelChangeSub = this.ngModel.modelUpdate$.subscribe(model => this.handleNgModelChanged.bind(this)(model));
}

ngOnChanges(changes: SimpleChanges): void {
if (this.options?.length && this?.ngModel?.selectedValues?.length) {
this.updateSelectionSummary((this.ngModel.selectedValues || []).map(o => this.value(o)));
}
}

ngAfterViewInit(): void {
this._itemTemplate = this._itemTemplate ? this.itemTemplate : this.defaultItemTemplate || null;
}
Expand Down

0 comments on commit 269b5d1

Please sign in to comment.