5
5
* Use of this source code is governed by an MIT-style license that can be
6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
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' ;
8
20
import { DOCUMENT } from '@angular/common' ;
9
21
import {
22
+ ChangeDetectorRef ,
10
23
Directive ,
11
24
ElementRef ,
12
25
EventEmitter ,
@@ -19,19 +32,8 @@ import {
19
32
Output ,
20
33
TemplateRef ,
21
34
ViewContainerRef ,
35
+ inject ,
22
36
} 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' ;
35
37
36
38
export type AriaHasPopupValue = 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' ;
37
39
export type OpenAction = 'focus' | 'click' | 'downKey' | 'toggle' ;
@@ -107,6 +109,8 @@ export class CdkCombobox<T = unknown> implements OnDestroy {
107
109
contentId : string = '' ;
108
110
contentType : AriaHasPopupValue ;
109
111
112
+ private _changeDetectorRef = inject ( ChangeDetectorRef ) ;
113
+
110
114
constructor (
111
115
private readonly _elementRef : ElementRef < HTMLElement > ,
112
116
private readonly _overlay : Overlay ,
@@ -193,6 +197,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy {
193
197
this . opened . next ( ) ;
194
198
this . _overlayRef = this . _overlayRef || this . _overlay . create ( this . _getOverlayConfig ( ) ) ;
195
199
this . _overlayRef . attach ( this . _getPanelContent ( ) ) ;
200
+ this . _changeDetectorRef . markForCheck ( ) ;
196
201
if ( ! this . _isTextTrigger ( ) ) {
197
202
// TODO: instead of using a focus function, potentially use cdk/a11y focus trapping
198
203
this . _doc . getElementById ( this . contentId ) ?. focus ( ) ;
@@ -205,6 +210,7 @@ export class CdkCombobox<T = unknown> implements OnDestroy {
205
210
if ( this . isOpen ( ) && ! this . disabled ) {
206
211
this . closed . next ( ) ;
207
212
this . _overlayRef . detach ( ) ;
213
+ this . _changeDetectorRef . markForCheck ( ) ;
208
214
}
209
215
}
210
216
0 commit comments