adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.64k stars 1.09k forks source link

Multiple auto-dismiss toasts #7024

Open brigittesaghie opened 1 week ago

brigittesaghie commented 1 week ago

Provide a general summary of the issue here

When you open multiple auto-dismiss toasts together and you close the first (top) toast, all other toasts stay paused. It should keep running and dismiss when the timeout is finished

๐Ÿค” Expected Behavior?

All toast should be dismissed after the timeout is finished when it's no longer hovered.

๐Ÿ˜ฏ Current Behavior

The other toasts stay paused and you will have to hover over the other toasts to get them back running.

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

  1. Open the example in this link
  2. Click the 'Show toast' button a couple of times
  3. Close the toast at the top
  4. You see can the toasts below are not closing after the timeout is finished

Version

0.1.1-beta.54

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

iOS

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

snowystinger commented 1 week ago

looks like this useHover onHoverEnd isn't called https://github.com/adobe/react-spectrum/blob/73414999fcc6afab5c4bc8ec4740fe3dc1eb8502/packages/%40react-aria/toast/src/useToastRegion.ts#L37 And it only happens if you dismiss the outer most toast such that the toast region become smaller behind the cursor. This means that in most browsers onPointerLeave isn't called.

It's debatable if it's a bug in the browsers or not, they've declined to take action on this so far. See https://github.com/adobe/react-spectrum/issues/3522 for some other related issues.

We may need to do some hit detection on toast region resize to determine if we're still hovering. Or we could delay the removal onPress by an immediate timeout or a microTask or something.