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

Fix #2981: let DEFAULT_TIMEOUT for Toasts be used #2982

Merged
merged 3 commits into from
Feb 3, 2021
Merged

Fix #2981: let DEFAULT_TIMEOUT for Toasts be used #2982

merged 3 commits into from
Feb 3, 2021

Conversation

brendanfalkowski
Copy link
Contributor

Description

Toasts don't use the DEFAULT_TIMEOUT which is defined, so developers must specify it in every instance.

Related Issue

Closes #2981.

Acceptance

Verification Stakeholders

Specification

Verification Steps

  1. Find an instance of addToast()
  2. Remove the timeout prop.
  3. It should fallback to the default specified in the hook.

Screenshots / Screen Captures (if appropriate)

Checklist

  • I have added tests to cover my changes, if necessary.
  • I have added translations for new strings, if necessary.
  • I have updated the documentation accordingly, if necessary.

@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Jan 30, 2021

Fails
🚫 A version label is required. A maintainer must add one.
Messages
📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

Generated by 🚫 dangerJS against 7c18f92

sirugh
sirugh previously requested changes Feb 1, 2021
Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

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

I want to say this is working as intended, but I'd happily concede the point if you can show me an example where this is not working properly.

@@ -113,7 +113,7 @@ export const useToasts = () => {
const {
dismissable,
message,
timeout,
timeout = DEFAULT_TIMEOUT,
Copy link
Contributor

Choose a reason for hiding this comment

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

We specifically did not do this because passing a timeout of 0 or false is allowable, and actually means "do not time out". We actually do use the default timeout later in the file:

// A timeout of 0 means no auto-dismiss.
let removalTimeoutId;
if (timeout !== 0 && timeout !== false) {
removalTimeoutId = setTimeout(
() => {
handleDismiss();
},
timeout ? timeout : DEFAULT_TIMEOUT
);
}

If you pass a timeout of 0 or false, it never times out (meaning the user has to close it manually).
If you pass a timeout of a number > 0, it uses times out after that.
If you do not pass a timeout, it times out after the DEFAULT_TIMEOUT.

Copy link
Contributor

Choose a reason for hiding this comment

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

We specifically did not do this because passing a timeout of 0 or false is allowable

Sure, but application of the default param here only happens if props.timeout is undefined. Seems like the right change to make to me, unless I'm missing something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My DevEx case was not wanting to pass any props that just reiterate what the logic determines to be default behavior. So { message, type } is better than having to remember { message, timeout, type } or { dismissable, message, type } every time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but application of the default param here only happens if props.timeout is undefined.

Huh, for some reason I thought it would not apply but I think I'm confusing defaultProps with destructured defaults.

@@ -113,7 +113,7 @@ export const useToasts = () => {
const {
dismissable,
message,
timeout,
timeout = DEFAULT_TIMEOUT,
Copy link
Contributor

Choose a reason for hiding this comment

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

We specifically did not do this because passing a timeout of 0 or false is allowable

Sure, but application of the default param here only happens if props.timeout is undefined. Seems like the right change to make to me, unless I'm missing something else.

@dpatil-magento dpatil-magento merged commit 1d45ad4 into magento:develop Feb 3, 2021
Frodigo pushed a commit to Frodigo/pwa-studio that referenced this pull request Feb 22, 2021
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
dpatil-magento added a commit that referenced this pull request 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: Toasts don't fallback to DEFAULT_TIMEOUT
5 participants