Skip to content
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

feat(snackbar): add timeout for snackbar #1856

Merged
merged 4 commits into from
Nov 17, 2016

Conversation

josephperrott
Copy link
Member

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 14, 2016
@@ -13,4 +13,7 @@ export class MdSnackBarConfig {

/** The view container to place the overlay for the snack bar into. */
viewContainerRef?: ViewContainerRef = null;

/** The length of time in milliseconds to wait before automatically dismissing the snack bar. */
autoHide?: number = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just call this duration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -64,6 +62,10 @@ export class MdSnackBar {
} else {
snackBarRef.containerInstance.enter();
}
if (config.autoHide > 0) {
setTimeout(() => snackBarRef.dismiss(), config.autoHide + 225);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the 225 baked in here? (I'm assuming it's the animation duration, but doesn't dismiss handle that already?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot I had this in there.

Yes, the 225 is for the animation. Created a todo to handle the case I was looking at.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


tick(1000);
viewContainerFixture.detectChanges();
viewContainerFixture.whenStable().then(() => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to use whenStable with fakeAsync because the whenStable will just be called synchronously.

(same for other uses)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to get my tests working without whenStable, so I will have to dig in more there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it works, not sure what happened before.

@@ -64,6 +62,10 @@ export class MdSnackBar {
} else {
snackBarRef.containerInstance.enter();
}
if (config.autoHide > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do config.duration && cofig.duration > 0 in case someone sets it to null or undefined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use strict null checking?

We can then use the Non-null assertion operator

for instance in this case it would be:

if (config.autoHide! > 0) {

@josephperrott josephperrott force-pushed the snackbartimeout branch 4 times, most recently from 98120fa to 296f38b Compare November 14, 2016 21:47
@josephperrott josephperrott force-pushed the snackbartimeout branch 4 times, most recently from a976d62 to 89f9b55 Compare November 16, 2016 02:49
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, I left this comment a day ago and never sent it.

@@ -13,4 +13,7 @@ export class MdSnackBarConfig {

/** The view container to place the overlay for the snack bar into. */
viewContainerRef?: ViewContainerRef = null;

/** The length of time in milliseconds to wait before automatically dismissing the snack bar. */
dismiss?: number = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duration?
(I think you may have brained one thing and keyboarded another)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -15,6 +15,7 @@
| `viewContainerRef: ViewContainerRef` | The view container ref to attach the snack bar to. |
| `role: AriaLivePoliteness = 'assertive'` | The politeness level to announce the snack bar with. |
| `announcementMessage: string` | The message to announce with the snack bar. |
| `dismiss: number` | The length of time in milliseconds to wait before autodismissing the snack bar. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed dismiss > duration here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jelbourn
Copy link
Member

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 17, 2016
@kara kara merged commit 6ce6396 into angular:master Nov 17, 2016
@josephperrott josephperrott deleted the snackbartimeout branch November 18, 2016 17:49
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants