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

Removing a Tag in a TagGroup with disabled Tags crashes the page #6616

Closed
kraine93 opened this issue Jun 25, 2024 · 2 comments · Fixed by #6621
Closed

Removing a Tag in a TagGroup with disabled Tags crashes the page #6616

kraine93 opened this issue Jun 25, 2024 · 2 comments · Fixed by #6621
Labels
bug Something isn't working release

Comments

@kraine93
Copy link

kraine93 commented Jun 25, 2024

Provide a general summary of the issue here

When combining two features of TagGroup - disabledKeys and onRemove - it's possible to crash the browser tab when removing a Tag.

This only seems to happen when there are at least two disabled Tags in the collection.

I'm able to reproduce in at least two ways:

  1. Remove all non-disabled Tags from a collection (ctrl-a + backspace), leaving only disabled Tags remaining.
  2. Remove the last Tag from the end of a collection where the (at least) two previous Tags are disabled.

It works fine when:

  • There is only one disabled Tag.
  • There is only one disabled Tag between the removed Tag and the next focusable Tag.

🤔 Expected Behavior?

The page should not crash and the next or previous non-disabled Tag should receive focus. If there are no remaining focusable Tags, the TagGroup or TagList should receive focus.

😯 Current Behavior

The page crashes.

💁 Possible Solution

At a guess, I would say that perhaps the TagGroup is struggling to find a valid target to move focus to when the element is removed.

🔦 Context

No response

🖥️ Steps to Reproduce

https://codesandbox.io/p/sandbox/exciting-hooks-6lhjcm

Delete the final tag 'Watermelon' to crash the tab.

Version

react-aria-components 1.2.1

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Windows

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@snowystinger
Copy link
Member

Yep, found the issue, I've created a PR to fix it. Thanks for reporting it

@snowystinger snowystinger added bug Something isn't working release labels Jun 26, 2024
@kraine93
Copy link
Author

Amazing! Thanks for the quick fix 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working release
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants