Skip to content

[snack-bar] onAction subject never completes #8181

@willshowell

Description

@willshowell

Bug, feature request, or proposal:

Bug

What is the current behavior?

Subscribing to onAction() will result in a subscription that never completes unless the action button is clicked.

Expected behavior

onAction() completes when the snackbar ref is destroyed, I suppose in _finishDismiss().

Reproduction

https://stackblitz.com/edit/angular-material2-issue-l1ymh2?file=app/app.component.ts

Motivation

I wish to open a snack-bar that has a duration longer than the expected lifetime of the component opening it. When the action is clicked, I would like to navigate to a new route.

I am unable to unsubscribe from the subscription in ngOnDestroy since the snackbar action may be available after the component is destroyed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions