File tree 1 file changed +12
-9
lines changed
1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { FocusKeyManager } from '@angular/cdk/a11y' ;
1
2
import {
2
3
AfterContentInit ,
3
4
booleanAttribute ,
4
5
computed ,
5
- ContentChildren ,
6
+ contentChildren ,
6
7
DestroyRef ,
7
8
Directive ,
8
9
ElementRef ,
9
10
forwardRef ,
10
11
inject ,
11
12
input ,
12
13
linkedSignal ,
13
- OnInit ,
14
- QueryList
14
+ OnInit
15
15
} from '@angular/core' ;
16
- import { FocusKeyManager } from '@angular/cdk/a11y' ;
17
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
16
+ import { takeUntilDestroyed , toObservable } from '@angular/core/rxjs-interop' ;
18
17
import { tap } from 'rxjs/operators' ;
19
18
20
19
import { ThemeDirective } from '../../shared/theme.directive' ;
@@ -98,13 +97,17 @@ export class DropdownMenuDirective implements OnInit, AfterContentInit {
98
97
}
99
98
}
100
99
101
- @ContentChildren ( forwardRef ( ( ) => DropdownItemDirective ) , { descendants : true } )
102
- dropdownItemsContent ! : QueryList < DropdownItemDirective > ;
100
+ readonly dropdownItemsContent = contentChildren < DropdownItemDirective > (
101
+ forwardRef ( ( ) => DropdownItemDirective ) ,
102
+ { descendants : true }
103
+ ) ;
104
+
105
+ readonly items$ = toObservable ( this . dropdownItemsContent ) ;
103
106
104
107
ngAfterContentInit ( ) : void {
105
108
this . focusKeyManagerInit ( ) ;
106
109
107
- this . dropdownItemsContent . changes
110
+ this . items$
108
111
. pipe (
109
112
tap ( ( change ) => {
110
113
this . focusKeyManagerInit ( ) ;
@@ -131,7 +134,7 @@ export class DropdownMenuDirective implements OnInit, AfterContentInit {
131
134
}
132
135
133
136
private focusKeyManagerInit ( ) : void {
134
- this . #focusKeyManager = new FocusKeyManager ( this . dropdownItemsContent )
137
+ this . #focusKeyManager = new FocusKeyManager ( this . dropdownItemsContent ( ) )
135
138
. withHomeAndEnd ( )
136
139
. withPageUpDown ( )
137
140
. withWrap ( )
You can’t perform that action at this time.
0 commit comments