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

Focused Toast removal with Escape key broken after 1.1.6-rc.1 #2906

Open
jaknas opened this issue May 17, 2024 · 1 comment
Open

Focused Toast removal with Escape key broken after 1.1.6-rc.1 #2906

jaknas opened this issue May 17, 2024 · 1 comment

Comments

@jaknas
Copy link

jaknas commented May 17, 2024

Bug report

Current Behavior

toast-escape-removal.mov

Currently, when more than 2 toasts are visible, and focus is move to the oldest toast, when clicking Escape, 2 Toasts are getting removed instead of the focused toast.

Expected behavior

Expectation is that only the focused toast is removed.

Reproducible example

CodeSandbox Template

  1. Open 3 toasts
  2. Move focus to the middle toast
  3. Press Escape
  4. 2 toasts are removed instead of a single, currently focused toast.

Suggested solution

According to my investigation (might be wrong though), after making the useEscapeKeyDown handler a capturing event listener, the order in which event handlers responsible for toast focus management are fired is reversed.

Previously:

  1. onKeyDown
  2. onEscapeKeyDown

Now:

  1. onEscapeKeyDown
  2. onKeyDown

This causes the ref flags to not be set in a correct ore

Additional context

The bug is caused by #2761

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/toast 1.1.6-rc.1
React n/a latest
Browser Chrome 125
Assistive tech
Node n/a
npm/yarn
Operating System MacOS 14.4.1
@jaknas jaknas changed the title Focused Toast removal with Escape key broken in 1.1.6-rc.1 Focused Toast removal with Escape key broken after 1.1.6-rc.1 Jun 24, 2024
@jaknas
Copy link
Author

jaknas commented Jun 24, 2024

This is also happening under recently released @radix-ui/react-toast@1.2.0

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

No branches or pull requests

1 participant