-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(snack-bar): indicate in afterDismissed whether dismissal was a result of an action #9154
fix(snack-bar): indicate in afterDismissed whether dismissal was a result of an action #9154
Conversation
src/lib/snack-bar/snack-bar-ref.ts
Outdated
@@ -84,13 +88,18 @@ export class MatSnackBarRef<T> { | |||
this._onAction.complete(); | |||
} | |||
|
|||
this._afterClosed.next(); | |||
this._afterClosed.complete(); | |||
this._afterDismissed.next(this._dismissedWithAction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josephperrott I'm also open to having a reason
parameter on the dismiss
method. I didn't go with it now, because it would mean that we'd need some magical string (e.g. 'action'
), because the consumer doesn't usually have access to the action button on the SimpleSnackBar
.
src/lib/snack-bar/snack-bar-ref.ts
Outdated
* The stream emits a boolean that indicates whether the snack bar was dismissed | ||
* using the action button. | ||
*/ | ||
afterDismissed(): Observable<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of making this a boolean stream, I'd rather add an event object so that we could add more information to it in the future.
40ac2ce
to
1522681
Compare
Addressed the feedback @jelbourn. |
src/lib/snack-bar/snack-bar-ref.ts
Outdated
@@ -11,6 +11,12 @@ import {Observable} from 'rxjs/Observable'; | |||
import {Subject} from 'rxjs/Subject'; | |||
import {MatSnackBarContainer} from './snack-bar-container'; | |||
|
|||
/** Event that is emitted when a snack bar is dismissed. */ | |||
export interface MatSnackBarAfterDismiss { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just MatSnackBarDismiss
or MatSnackBarDismissal
? The "after" in the stream name makes sense because it relates to when the event is emitted, but there's nothing about the event object that's specific to it being at that time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to MatSnackBarDismiss
.
1522681
to
045aefb
Compare
src/lib/snack-bar/snack-bar-ref.ts
Outdated
/** Event that is emitted when a snack bar is dismissed. */ | ||
export interface MatSnackBarDismiss { | ||
/** Whether the snack bar was dismissied using the action button. */ | ||
dismissedByAction: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be closedByAction
since the method that would cause this to be true is closeWithAction()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but the method that returns it is called afterDismissed
. Either way it would be slightly confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should mark one of the terms as deprecated to fix it long term? I am good with either wording being removed, just as long as we create consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My vote is for removing the "dismissed" wording and calling it "close" (also renaming the dismiss
method). That way it's consistent with the dialog as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
045aefb
to
846ba98
Compare
Done @josephperrott. |
My opinion: |
…sult of an action Adds a boolean to the `MatSnackBarRef.afterDismissed` result that indicates whether the dismissal came as a result of the user pressing the action button. Fixes angular#9147.
846ba98
to
e378824
Compare
Switched back to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a boolean to the
MatSnackBarRef.afterDismissed
result that indicates whether the dismissal came as a result of the user pressing the action button.Fixes #9147.