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 removing toast correctly #1

Merged
merged 2 commits into from
Aug 2, 2024
Merged

fix removing toast correctly #1

merged 2 commits into from
Aug 2, 2024

Conversation

ultrox
Copy link
Owner

@ultrox ultrox commented Aug 2, 2024

fixes timolins/react-hot-toast#367 from upstream

I've had a look and found out that this fix only works correctly if you remove all toasts, which toast.remove does as it's overloaded (undefined removes all). Actually I would prefer removeById, but that's another discussion.

I found out that what is not happening is that when you click 'remove' the PAUSE_END action is not fired (onMouseLeave is not triggered).

Either fire this action on remove and dismiss, or extract the logic of this PAUSE_END into a separate function and reuse.

You need to do this because the current fix does not count on the pauseDuration being adjusted. This is revealed when you remove by id and then they all disappear at once after the largest pause, which is not the desired behaviour.

Finally, this is a really tricky bug because `dismiss' is also affected, but because dismiss hides the toast, you accidentally trigger END_PAUSE because wrapper is there and onMouseLeave triggers.

Copy link

stackblitz bot commented Aug 2, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ultrox ultrox merged commit aa53acf into main Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Click the "dismiss/remove" button in the message component will make the duration not work later
1 participant