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

Remove toast explicitly even on focus #220

Closed
jstawski opened this issue Dec 1, 2014 · 9 comments
Closed

Remove toast explicitly even on focus #220

jstawski opened this issue Dec 1, 2014 · 9 comments

Comments

@jstawski
Copy link
Contributor

jstawski commented Dec 1, 2014

Looking at the source code the toast doesn't get removed if there is focus on an element. I imagine that was done so the toast wouldn't get cleared automatically by the timer if you are working on it.

Shouldn't we allow the removal of the toast if we explicit call the remove? After all I am the developer and I know what I'm doing.

By the way the same thing happens with clear

@johnpapa
Copy link
Member

@jstawski Wanna open a PR for this?

@TimFerrell do you agree that remove and clear should do this even if focus is on the toast?

@TimFerrell
Copy link
Member

I can understand the use case, but I'm not entirely sure why that guard around the focus existed to begin with. I'd like to figure the history behind it before removing it outright.

Additionally, I'm hesitant to make clearing a focused item if that's the functionality devs have come to rely on. In the event that we change the default functionality, should we introduce an option to restore the older functionality? Might be slipping into over-configuration, though.

@johnpapa
Copy link
Member

My thought was that if you are hovering over the toast, it should stick around. Think of how an outlook or growl notification works ... if you want it to stick around longer so you can read it, you hover, then it resets the timeout. So I want to keep that here, because without that delay the toast would disappear to soon.

But I see Jonas' point. If he explicitly clears it, perhaps it should go away. I'm not sure of the exact use case for that tho. @jstawski can you clarify?

@jstawski
Copy link
Contributor Author

@johnpapa @TimFerrell we show a generic error using the toastr when there are validation errors (besides the actual validation errors) and leave the toast up forever. When we change the view based on user input or clear the error outs, we want to also get rid of the toast programatically.

I think we should add a boolean paramater to the clear/remove functions that allow it to check for focus or not and default it so it is backward compatible. Another option would be to add more API level functions for explicit clearing and it would not be used by the timeouts.

EDIT: Toastr works great with the use case mentioned above. I got confused it with another problem we were having. The real use case is when you want a toast to have a button that removes itself. Read the comments below for a jsfiddle example.

@TimFerrell
Copy link
Member

I like the idea of overriding the clear function.

@TimFerrell
Copy link
Member

@jstawski - care to create a PR with the modification?

@jstawski
Copy link
Contributor Author

@TimFerrell will definitely create one, do you have any documentation I should follow for this project for PR? Unit tests, naming conventions, standards?

@jstawski
Copy link
Contributor Author

@TimFerrell @johnpapa by the way here's a jsfiddle of the problem in action. A toast can't clear itself out with a button.

@TimFerrell
Copy link
Member

Closing because PR was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants