-
Notifications
You must be signed in to change notification settings - Fork 687
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
Fix #2981: let DEFAULT_TIMEOUT for Toasts be used #2982
Conversation
|
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.
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, |
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.
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:
pwa-studio/packages/peregrine/lib/Toasts/useToasts.js
Lines 149 to 158 in 9edff92
// 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
.
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.
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.
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 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.
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.
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, |
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.
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.
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
* [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>
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
addToast()
timeout
prop.Screenshots / Screen Captures (if appropriate)
Checklist