Skip to content

Commit ea0aed5

Browse files
committed
refactor(material/menu): use ID generator
Switches to using the ID generator service to create unique IDs.
1 parent 43d58eb commit ea0aed5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/material/menu/menu.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
Injector,
3232
} from '@angular/core';
3333
import {AnimationEvent} from '@angular/animations';
34-
import {FocusKeyManager, FocusOrigin} from '@angular/cdk/a11y';
34+
import {_IdGenerator, FocusKeyManager, FocusOrigin} from '@angular/cdk/a11y';
3535
import {Direction} from '@angular/cdk/bidi';
3636
import {
3737
ESCAPE,
@@ -50,8 +50,6 @@ import {throwMatMenuInvalidPositionX, throwMatMenuInvalidPositionY} from './menu
5050
import {MatMenuContent, MAT_MENU_CONTENT} from './menu-content';
5151
import {matMenuAnimations} from './menu-animations';
5252

53-
let menuPanelUid = 0;
54-
5553
/** Reason why the menu was closed. */
5654
export type MenuCloseReason = void | 'click' | 'keydown' | 'tab';
5755

@@ -270,7 +268,7 @@ export class MatMenu implements AfterContentInit, MatMenuPanel<MatMenuItem>, OnI
270268
*/
271269
@Output() readonly close: EventEmitter<MenuCloseReason> = this.closed;
272270

273-
readonly panelId = `mat-menu-panel-${menuPanelUid++}`;
271+
readonly panelId: string = inject(_IdGenerator).getId('mat-menu-panel-');
274272

275273
private _injector = inject(Injector);
276274

0 commit comments

Comments
 (0)