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 {
3737export class ActiveDescendantKeyManager <T > extends ListKeyManager <Highlightable & T > {
3838 setActiveItem(index : number ): void ;
3939 setActiveItem(item : T ): void ;
40+ setActiveItem(item : T | number ): void ;
4041}
4142
4243// @public
@@ -169,6 +170,7 @@ export interface FocusableOption extends ListKeyManagerOption {
169170export class FocusKeyManager <T > extends ListKeyManager <FocusableOption & T > {
170171 setActiveItem(index : number ): void ;
171172 setActiveItem(item : T ): void ;
173+ setActiveItem(item : T | number ): void ;
172174 setFocusOrigin(origin : FocusOrigin ): this ;
173175}
174176
@@ -366,6 +368,7 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
366368 onKeydown(event : KeyboardEvent ): void ;
367369 setActiveItem(index : number ): void ;
368370 setActiveItem(item : T ): void ;
371+ setActiveItem(item : T | number ): void ;
369372 setFirstItemActive(): void ;
370373 setLastItemActive(): void ;
371374 setNextItemActive(): void ;
Original file line number Diff line number Diff line change @@ -37,6 +37,13 @@ export class ActiveDescendantKeyManager<T> extends ListKeyManager<Highlightable
3737 * @param item Item to be set as active.
3838 */
3939 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 ;
4047
4148 override setActiveItem ( index : any ) : void {
4249 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> {
4444 */
4545 override setActiveItem ( item : T ) : void ;
4646
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+
4753 override setActiveItem ( item : any ) : void {
4854 super . setActiveItem ( item ) ;
4955
Original file line number Diff line number Diff line change @@ -203,6 +203,12 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
203203 */
204204 setActiveItem ( item : T ) : void ;
205205
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+
206212 setActiveItem ( item : any ) : void {
207213 const previousActiveItem = this . _activeItem ( ) ;
208214
Original file line number Diff line number Diff line change @@ -146,13 +146,7 @@ export abstract class CdkMenuBase
146146 * @param item The index of the item to be set as active, or the CdkMenuItem instance.
147147 */
148148 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 ) ;
156150 }
157151
158152 /** Gets the tabindex for this menu. */
You can’t perform that action at this time.
0 commit comments