File tree Expand file tree Collapse file tree 5 files changed +23
-7
lines changed Expand file tree Collapse file tree 5 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export class A11yModule {
37
37
export class ActiveDescendantKeyManager <T > extends ListKeyManager <Highlightable & T > {
38
38
setActiveItem(index : number ): void ;
39
39
setActiveItem(item : T ): void ;
40
+ setActiveItem(item : T | number ): void ;
40
41
}
41
42
42
43
// @public
@@ -169,6 +170,7 @@ export interface FocusableOption extends ListKeyManagerOption {
169
170
export class FocusKeyManager <T > extends ListKeyManager <FocusableOption & T > {
170
171
setActiveItem(index : number ): void ;
171
172
setActiveItem(item : T ): void ;
173
+ setActiveItem(item : T | number ): void ;
172
174
setFocusOrigin(origin : FocusOrigin ): this ;
173
175
}
174
176
@@ -366,6 +368,7 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
366
368
onKeydown(event : KeyboardEvent ): void ;
367
369
setActiveItem(index : number ): void ;
368
370
setActiveItem(item : T ): void ;
371
+ setActiveItem(item : T | number ): void ;
369
372
setFirstItemActive(): void ;
370
373
setLastItemActive(): void ;
371
374
setNextItemActive(): void ;
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ export class ActiveDescendantKeyManager<T> extends ListKeyManager<Highlightable
37
37
* @param item Item to be set as active.
38
38
*/
39
39
override setActiveItem ( item : T ) : void ;
40
+ /**
41
+ * Sets the active item to the item to the specified one and adds the
42
+ * active styles to the it. Also removes active styles from the
43
+ * previously active item.
44
+ * @param item Item to be set as active.
45
+ */
46
+ override setActiveItem ( item : T | number ) : void ;
40
47
41
48
override setActiveItem ( index : any ) : void {
42
49
if ( this . activeItem ) {
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ export class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {
44
44
*/
45
45
override setActiveItem ( item : T ) : void ;
46
46
47
+ /**
48
+ * Sets the active item to the item that is specified and focuses it.
49
+ * @param item Item to be set as active.
50
+ */
51
+ override setActiveItem ( item : T | number ) : void ;
52
+
47
53
override setActiveItem ( item : any ) : void {
48
54
super . setActiveItem ( item ) ;
49
55
Original file line number Diff line number Diff line change @@ -203,6 +203,12 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
203
203
*/
204
204
setActiveItem ( item : T ) : void ;
205
205
206
+ /**
207
+ * Sets the active item to the specified item.
208
+ * @param item The item to be set as active.
209
+ */
210
+ setActiveItem ( item : T | number ) : void ;
211
+
206
212
setActiveItem ( item : any ) : void {
207
213
const previousActiveItem = this . _activeItem ( ) ;
208
214
Original file line number Diff line number Diff line change @@ -146,13 +146,7 @@ export abstract class CdkMenuBase
146
146
* @param item The index of the item to be set as active, or the CdkMenuItem instance.
147
147
*/
148
148
setActiveMenuItem ( item : number | CdkMenuItem ) {
149
- if ( this . keyManager ) {
150
- if ( typeof item === 'number' ) {
151
- this . keyManager . setActiveItem ( item ) ;
152
- } else {
153
- this . keyManager . setActiveItem ( item ) ;
154
- }
155
- }
149
+ this . keyManager ?. setActiveItem ( item ) ;
156
150
}
157
151
158
152
/** Gets the tabindex for this menu. */
You can’t perform that action at this time.
0 commit comments