[core] fix: toasters closing immediately on hover if timeout
is set to 0
#6783
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #6742, which was a regression from #6656 /
@blueprintjs/core@5.9.0
.Context
The docs specify that a
timeout
prop of0
will cause toasts to persist until a user manually dismisses it.Problem
In a semi-recent refactor of the
<OverlayToaster>
component, atimeout
value of0
caused the toaster to instead be immediately dismissed. Note how hovering in and out of a progress toast causes it to disappear.before.mov
Explanation
The new
<Toast2>
implementation does properly check if thetimeout
prop is0
or negative on initial mount.blueprint/packages/core/src/components/toast/toast2.tsx
Lines 54 to 57 in 488658d
However, it's incorrect on the pause/resume timeout logic that happens when users mouse over a toaster. This logic always starts a timeout on mouse out, even if the timeout is
0
. The original<Toast>
implementation didn't do this.blueprint/packages/core/src/components/toast/toast2.tsx
Lines 87 to 88 in 488658d
Changes
Copying the logic from the original implementation, which doesn't schedule a timeout at all if it's
0
.https://github.com/palantir/blueprint/blob/9dfba77ec5094c7752e5b73eb49a7e72dced9dcb/packages/core/src/components/toast/toast.tsx#L117-LL122
after.mov