55 * Use of this source code is governed by an MIT-style license that can be
66 * found in the LICENSE file at https://angular.io/license
77 */
8+ import { Directionality } from '@angular/cdk/bidi' ;
9+ import { BooleanInput , coerceArray , coerceBooleanProperty } from '@angular/cdk/coercion' ;
10+ import { DOWN_ARROW , ENTER , ESCAPE , TAB } from '@angular/cdk/keycodes' ;
11+ import {
12+ ConnectedPosition ,
13+ FlexibleConnectedPositionStrategy ,
14+ Overlay ,
15+ OverlayConfig ,
16+ OverlayRef ,
17+ } from '@angular/cdk/overlay' ;
18+ import { _getEventTarget } from '@angular/cdk/platform' ;
19+ import { TemplatePortal } from '@angular/cdk/portal' ;
820import { DOCUMENT } from '@angular/common' ;
921import {
22+ ChangeDetectorRef ,
1023 Directive ,
1124 ElementRef ,
1225 EventEmitter ,
@@ -19,19 +32,8 @@ import {
1932 Output ,
2033 TemplateRef ,
2134 ViewContainerRef ,
35+ inject ,
2236} from '@angular/core' ;
23- import { TemplatePortal } from '@angular/cdk/portal' ;
24- import {
25- ConnectedPosition ,
26- FlexibleConnectedPositionStrategy ,
27- Overlay ,
28- OverlayConfig ,
29- OverlayRef ,
30- } from '@angular/cdk/overlay' ;
31- import { Directionality } from '@angular/cdk/bidi' ;
32- import { BooleanInput , coerceArray , coerceBooleanProperty } from '@angular/cdk/coercion' ;
33- import { _getEventTarget } from '@angular/cdk/platform' ;
34- import { DOWN_ARROW , ENTER , ESCAPE , TAB } from '@angular/cdk/keycodes' ;
3537
3638export type AriaHasPopupValue = 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' ;
3739export type OpenAction = 'focus' | 'click' | 'downKey' | 'toggle' ;
@@ -107,6 +109,8 @@ export class CdkCombobox<T = unknown> implements OnDestroy {
107109 contentId : string = '' ;
108110 contentType : AriaHasPopupValue ;
109111
112+ private _changeDetectorRef = inject ( ChangeDetectorRef ) ;
113+
110114 constructor (
111115 private readonly _elementRef : ElementRef < HTMLElement > ,
112116 private readonly _overlay : Overlay ,
@@ -193,6 +197,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy {
193197 this . opened . next ( ) ;
194198 this . _overlayRef = this . _overlayRef || this . _overlay . create ( this . _getOverlayConfig ( ) ) ;
195199 this . _overlayRef . attach ( this . _getPanelContent ( ) ) ;
200+ this . _changeDetectorRef . markForCheck ( ) ;
196201 if ( ! this . _isTextTrigger ( ) ) {
197202 // TODO: instead of using a focus function, potentially use cdk/a11y focus trapping
198203 this . _doc . getElementById ( this . contentId ) ?. focus ( ) ;
@@ -205,6 +210,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy {
205210 if ( this . isOpen ( ) && ! this . disabled ) {
206211 this . closed . next ( ) ;
207212 this . _overlayRef . detach ( ) ;
213+ this . _changeDetectorRef . markForCheck ( ) ;
208214 }
209215 }
210216
0 commit comments