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

[bug]: Toasts don't fallback to DEFAULT_TIMEOUT #2981

Closed
1 of 8 tasks
brendanfalkowski opened this issue Jan 30, 2021 · 7 comments · Fixed by #2982
Closed
1 of 8 tasks

[bug]: Toasts don't fallback to DEFAULT_TIMEOUT #2981

brendanfalkowski opened this issue Jan 30, 2021 · 7 comments · Fixed by #2982
Assignees
Labels
bug Something isn't working Progress: done

Comments

@brendanfalkowski
Copy link
Contributor

Describe the bug

The useToasts hook appears to support a DEFAULT_TIMEOUT but the way it's implemented it can't be used.

You shouldn't need to specify the timeout every time a Toast is added.

To reproduce

Steps to reproduce the behavior:

  1. Add a toast anywhere
  2. But don't pass the timeout prop

Expected behavior

The Toast should timeout after the DEFAULT_TIMEOUT value specified in the hook.

What Actually Happens

Not passing timeout results in a TypeError. This means that every instance adding a Toast must specify the value which is bad for consistency.

Possible solutions

I will PR a fix shortly.

Please let us know what packages this bug is in regards to:

  • venia-concept
  • venia-ui
  • pwa-buildpack
  • peregrine
  • pwa-devdocs
  • upward-js
  • upward-spec
  • create-pwa
@brendanfalkowski brendanfalkowski added the bug Something isn't working label Jan 30, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jan 30, 2021

Hi @brendanfalkowski. Thank you for your report.
To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


@brendanfalkowski
Copy link
Contributor Author

@magento I am working on this

@sirugh
Copy link
Contributor

sirugh commented Feb 1, 2021

You shouldn't need to specify the timeout every time a Toast is added.

Yea, the docs indicate the prop is optional. And the code reads like it should function without it. I'm curious what the error is.

Edit:

I threw a toast into useApp and did not specify timeout and got an error that seemed pretty self explanatory.

TypeError: Toast should be user-dismissable or have a timeout

Adding dismissable: true (and no timeout) to the addToast args stopped the error from throwing and dismissed the toast after the default timeout.

@brendanfalkowski
Copy link
Contributor Author

@sirugh Hmm, that seems to just trade timeout for a different prop dismissable that needs to be specified. The normal behavior for toasts (in wider use) seems to be they default to self-dismissing. Just short confirmations that don't really require attention or action, unless you override it.

Ideally, the mental footprint to use it should be low so it's just { message, type } being passed in most cases. It still seems weird to have to specify dismissable: true when there should be a default timeout.

We ended up modifying this to fit the behavior of this pattern in our M1 site to support a title prop as well, and just applying the DEFAULT_TIMEOUT as a param fallback seemed like the cleanest fix for how we use it. But I might be misunderstanding the intent.

@sirugh
Copy link
Contributor

sirugh commented Feb 1, 2021

But I might be misunderstanding the intent.

@brendanfalkowski maybe :D I wrote this stuff almost two years ago and I've slept very little since then so we're in the same boat. At some point it might be worth it for us to clean up the toast implementation. For now, I think we can just accept your PR as is.

Also, sorry about the spam on this issue - we're trying to figure something out with our jira-github sync tool.

@github-jira-sync-bot
Copy link

✅ Jira ticket "PWA-1382" is successfully created for this issue.

@brendanfalkowski
Copy link
Contributor Author

@sirugh I hear you. I wrote myself the // TODO: why do we have to specify timeout in every call? comment 7 months ago, and just ran across it again last week, so debugged. Eventually, it gets better.

dpatil-magento added a commit that referenced this issue Feb 3, 2021
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
Frodigo pushed a commit to Frodigo/pwa-studio that referenced this issue Feb 22, 2021
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
dpatil-magento added a commit that referenced this issue Mar 17, 2021
* [feature]: Basic desktop improvements for Venia - Mega Menu #2805
 * added GraphQL query for Mega menu
 * added useMegaMenu talon
 * added MegaMenu component
 * added MegaMenuItem component
 * added Submenu component
 * added SubmenuColumn component
 * added MegaMenu to Header
 * added styles for Mega Menu
 * modified styles for header

* Added improvements for MegaMenu

* Update prettier config (#2900)

Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>

* #2981: let DEFAULT_TIMEOUT for Toasts be used (#2982)

Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>

* - Version bumps (#2983)

- Remove comment causing deprecation warning
- Fix test that was mocking the filesystem causing upstream deps to fail

Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>

* Visual adjustements for mega menu

* Mega menu - CR fixes

* Fixed mega menu initial state if cache data does not exist

* A few fixes -
unset active category on home/search
use callbacks vs inline functions
fixed some comments and prop ordering

Signed-off-by: sirugh <rugh@adobe.com>

* Handle null or empty url suffix

Signed-off-by: sirugh <rugh@adobe.com>

* forgot one

Signed-off-by: sirugh <rugh@adobe.com>

Co-authored-by: Piyush Dankhra <dankhrapiyush@gmail.com>
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
Co-authored-by: Brendan Falkowski <brendan@gravitydept.com>
Co-authored-by: Tommy Wiebell <twiebell@adobe.com>
Co-authored-by: sirugh <rugh@adobe.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Progress: done
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants