From 69968510fb0222ee565f57171640a99768efa972 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 31 Oct 2024 14:02:00 +0100 Subject: [PATCH] refactor(material/snack-bar): use ID generator Switches to using the ID generator service to create unique IDs. --- src/material/snack-bar/snack-bar-container.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/material/snack-bar/snack-bar-container.ts b/src/material/snack-bar/snack-bar-container.ts index 2a0ca64ab2d3..0f205c075058 100644 --- a/src/material/snack-bar/snack-bar-container.ts +++ b/src/material/snack-bar/snack-bar-container.ts @@ -29,13 +29,11 @@ import { TemplatePortal, } from '@angular/cdk/portal'; import {Observable, Subject} from 'rxjs'; -import {AriaLivePoliteness} from '@angular/cdk/a11y'; +import {_IdGenerator, AriaLivePoliteness} from '@angular/cdk/a11y'; import {Platform} from '@angular/cdk/platform'; import {AnimationEvent} from '@angular/animations'; import {MatSnackBarConfig} from './snack-bar-config'; -let uniqueId = 0; - /** * Internal component that wraps user-provided snack bar content. * @docs-private @@ -109,7 +107,7 @@ export class MatSnackBarContainer extends BasePortalOutlet implements OnDestroy _role?: 'status' | 'alert'; /** Unique ID of the aria-live element. */ - readonly _liveElementId = `mat-snack-bar-container-live-${uniqueId++}`; + readonly _liveElementId = inject(_IdGenerator).getId('mat-snack-bar-container-live-'); constructor(...args: unknown[]);