Skip to content

Commit 62a1cdb

Browse files
committed
refactor(material/expansion): use ID generator
Switches to using the ID generator service to create unique IDs.
1 parent 8c073c5 commit 62a1cdb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/material/expansion/expansion-panel.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
ANIMATION_MODULE_TYPE,
3333
inject,
3434
} from '@angular/core';
35+
import {_IdGenerator} from '@angular/cdk/a11y';
3536
import {Subject} from 'rxjs';
3637
import {filter, startWith, take} from 'rxjs/operators';
3738
import {MatAccordionBase, MatAccordionTogglePosition, MAT_ACCORDION} from './accordion-base';
@@ -42,9 +43,6 @@ import {MatExpansionPanelContent} from './expansion-panel-content';
4243
/** MatExpansionPanel's states. */
4344
export type MatExpansionPanelState = 'expanded' | 'collapsed';
4445

45-
/** Counter for generating unique element ids. */
46-
let uniqueId = 0;
47-
4846
/**
4947
* Object that can be used to override the default options
5048
* for all of the expansion panels in a module.
@@ -145,7 +143,7 @@ export class MatExpansionPanel
145143
_portal: TemplatePortal;
146144

147145
/** ID for the associated header element. Used for a11y labelling. */
148-
_headerId = `mat-expansion-panel-header-${uniqueId++}`;
146+
_headerId: string = inject(_IdGenerator).getId('mat-expansion-panel-header-');
149147

150148
constructor(...args: unknown[]);
151149

0 commit comments

Comments
 (0)