Skip to content

Commit

Permalink
refactor(material/snack-bar): use ID generator
Browse files Browse the repository at this point in the history
Switches to using the ID generator service to create unique IDs.

(cherry picked from commit 6996851)
  • Loading branch information
crisbeto committed Nov 4, 2024
1 parent 755bf1a commit f2589b8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/material/snack-bar/snack-bar-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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[]);

Expand Down

0 comments on commit f2589b8

Please sign in to comment.