Skip to content

Commit 0d7247b

Browse files
committed
fix: use AfterViewInit instead of AfterContentInit
1 parent 3b51afb commit 0d7247b

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

src/modules/select/classes/select-base.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
ViewChild, HostBinding, ElementRef, HostListener, Input, ContentChildren, QueryList,
3-
AfterContentInit, TemplateRef, ViewContainerRef, ContentChild, EventEmitter, Output, OnDestroy
3+
TemplateRef, ViewContainerRef, ContentChild, EventEmitter, Output, OnDestroy, AfterViewInit
44
} from "@angular/core";
55
import { Subscription } from "rxjs";
66
import { DropdownService, SuiDropdownMenu } from "../../dropdown/internal";
@@ -16,11 +16,11 @@ export interface IOptionContext<T> extends ITemplateRefContext<T> {
1616

1717
// We use generic type T to specify the type of the options we are working with,
1818
// and U to specify the type of the property of the option used as the value.
19-
export abstract class SuiSelectBase<T, U> implements AfterContentInit, OnDestroy {
19+
export abstract class SuiSelectBase<T, U> implements AfterViewInit, OnDestroy {
2020
public dropdownService:DropdownService;
2121
public searchService:SearchService<T, U>;
2222

23-
@ViewChild(SuiDropdownMenu, { static: true })
23+
@ViewChild(SuiDropdownMenu)
2424
protected _menu:SuiDropdownMenu;
2525

2626
// Keep track of all of the rendered select options. (Rendered by the user using *ngFor).
@@ -42,7 +42,10 @@ export abstract class SuiSelectBase<T, U> implements AfterContentInit, OnDestroy
4242

4343
@HostBinding("class.visible")
4444
public get isVisible():boolean {
45-
return this._menu.isVisible;
45+
if (this._menu) {
46+
return this._menu?.isVisible;
47+
}
48+
return false;
4649
}
4750

4851
@Input()
@@ -245,7 +248,7 @@ export abstract class SuiSelectBase<T, U> implements AfterContentInit, OnDestroy
245248
this.hasClasses = true;
246249
}
247250

248-
public ngAfterContentInit():void {
251+
public ngAfterViewInit():void {
249252
this._menu.service = this.dropdownService;
250253
// We manually specify the menu items to the menu because the @ContentChildren doesn't pick up our dynamically rendered items.
251254
this._menu.items = this._renderedOptions;
@@ -286,7 +289,7 @@ export abstract class SuiSelectBase<T, U> implements AfterContentInit, OnDestroy
286289
// The search delay is set to the transition duration to ensure results
287290
// aren't rendered as the select closes as that causes a sudden flash.
288291
if (delayed) {
289-
this.searchService.searchDelay = this._menu.menuTransitionDuration;
292+
this.searchService.searchDelay = this._menu?.menuTransitionDuration;
290293
this.searchService.updateQueryDelayed("");
291294
} else {
292295
this.searchService.updateQuery("");

src/modules/select/components/multi-select.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { Component, HostBinding, ElementRef, EventEmitter, Output, Input, Directive } from "@angular/core";
1+
import {
2+
Component,
3+
HostBinding,
4+
ElementRef,
5+
EventEmitter,
6+
Output,
7+
Input,
8+
Directive
9+
} from "@angular/core";
210
import { ICustomValueAccessorHost, KeyCode, customValueAccessorFactory, CustomValueAccessor } from "../../../misc/util/internal";
311
import { SuiLocalizationService } from "../../../behaviors/localization/internal";
412
import { SuiSelectBase } from "../classes/select-base";

src/modules/select/components/select.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Component, ViewContainerRef, ViewChild, Output, EventEmitter, ElementRef, Directive, Input } from "@angular/core";
1+
import {
2+
Component,
3+
ViewContainerRef,
4+
ViewChild,
5+
Output,
6+
EventEmitter,
7+
ElementRef,
8+
Directive,
9+
Input
10+
} from "@angular/core";
211
import { ICustomValueAccessorHost, customValueAccessorFactory, CustomValueAccessor } from "../../../misc/util/internal";
312
import { SuiLocalizationService } from "../../../behaviors/localization/internal";
413
import { SuiSelectBase } from "../classes/select-base";

src/modules/select/public.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
export {
22
SuiSelectModule,
3-
IOptionContext,
4-
SuiSelect,
5-
SuiSelectOption,
6-
SuiSelectSearch,
7-
SuiSelectValueAccessor,
8-
SuiMultiSelect,
9-
SuiMultiSelectValueAccessor
3+
IOptionContext
104
} from "./internal";

0 commit comments

Comments
 (0)