Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export class SnackBarOverviewExample {
constructor(private _snackBar: MatSnackBar) {}

openSnackBar(message: string, action: string) {
this._snackBar.open(message, action, {
duration: 2000,
});
this._snackBar.open(message, action);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export class SnackBarPositionExample {
constructor(private _snackBar: MatSnackBar) {}

openSnackBar() {
this._snackBar.open('Cannonball!!', 'End now', {
duration: 500,
this._snackBar.open('Cannonball!!', 'Splash', {
horizontalPosition: this.horizontalPosition,
verticalPosition: this.verticalPosition,
});
Expand Down
12 changes: 5 additions & 7 deletions src/material/snack-bar/snack-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,14 @@ Snack-bar messages are announced via an `aria-live` region. By default, the `pol
used. While `polite` is recommended, this can be customized by setting the `politeness` property of
the `MatSnackBarConfig`.

Focus is not, and should not be, moved to the snack-bar element. Moving the focus would be
disruptive to a user in the middle of a workflow. It is recommended that, for any action offered
in the snack-bar, the application offers the user an alternative way to perform the action.
Focus is not moved to the snack-bar element as that would be disruptive to a user in the middle of a workflow.
It is recommended that, for any action offered in the snack-bar, the application offers the user an
alternative way to perform the action.
Alternative interactions are typically keyboard shortcuts or menu options. When the action is
performed in this way, the snack-bar should be dismissed.
performed in this way, the snack-bar should be dismissed. A snack-bar can contain a single action.
"Dismiss" or "cancel" actions are optional.

Snack-bars that have an action available should not be given a `duration`, as to accommodate
screen-reader users that want to navigate to the snack-bar element to activate the action. If the
user has manually moved their focus within the snackbar, focus should be placed somewhere sensible
based on the application context when the snack-bar is dismissed.

Don't use "Dismiss" as a snack-bar-action, instead preferring to use a `duration` when there is
no additional action associated with the notification.