From 3f33cd1acd809fe2426f7f5f2732165ffa0e58c7 Mon Sep 17 00:00:00 2001 From: Samuel Renier Date: Fri, 18 Feb 2022 17:53:12 +0100 Subject: [PATCH] fix setter var active Error in commit ceccdcac1de4316cc33a1067d604a6470c0245ba --- .../typeahead-container.component.ts | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/typeahead/typeahead-container.component.ts b/src/typeahead/typeahead-container.component.ts index 0bcf48e596..93eb9a6622 100644 --- a/src/typeahead/typeahead-container.component.ts +++ b/src/typeahead/typeahead-container.component.ts @@ -121,6 +121,13 @@ export class TypeaheadContainerComponent implements OnDestroy { set active(active: TypeaheadMatch | undefined) { this._active = active; + + let preview; + if (!(this._active == null || this._active.isHeader())) { + preview = active; + } + this.parent?.typeaheadOnPreview.emit(preview); + this.activeChanged(); } @@ -145,7 +152,7 @@ export class TypeaheadContainerComponent implements OnDestroy { } if (this.typeaheadIsFirstItemActive && this._matches.length > 0) { - this.setActive(this._matches[0]); + this.active = this._matches[0]; if (this._active?.isHeader()) { this.nextActiveMatch(); @@ -225,9 +232,9 @@ export class TypeaheadContainerComponent implements OnDestroy { } const index = this.matches.indexOf(this._active); - this.setActive(this.matches[ + this.active = this.matches[ index - 1 < 0 ? this.matches.length - 1 : index - 1 - ]); + ]; if (this._active.isHeader()) { this.prevActiveMatch(); @@ -240,9 +247,9 @@ export class TypeaheadContainerComponent implements OnDestroy { nextActiveMatch(): void { const index = this._active ? this.matches.indexOf(this._active) : -1; - this.setActive(this.matches[ + this.active = this.matches[ index + 1 > this.matches.length - 1 ? 0 : index + 1 - ]); + ]; if (this._active?.isHeader()) { this.nextActiveMatch(); @@ -255,7 +262,7 @@ export class TypeaheadContainerComponent implements OnDestroy { selectActive(value: TypeaheadMatch): void { this.isFocused = true; - this.setActive(value); + this.active = value; } highlight(match: TypeaheadMatch, query: string[] | string): string { @@ -300,7 +307,7 @@ export class TypeaheadContainerComponent implements OnDestroy { focusLost(): void { this.isFocused = false; if (!this.canSelectItemsOnBlur) { - this.setActive(void 0); + this.active = void 0; } } @@ -375,15 +382,6 @@ export class TypeaheadContainerComponent implements OnDestroy { this.positionServiceSubscription.unsubscribe(); } - protected setActive(value?: TypeaheadMatch): void { - this._active = value; - let preview; - if (!(this._active == null || this._active.isHeader())) { - preview = value; - } - this.parent?.typeaheadOnPreview.emit(preview); - } - private isScrolledIntoView(elem: HTMLElement): boolean { if (!this.ulElement) { return false;