Skip to content

fix: focus restoring in collections#9545

Open
snowystinger wants to merge 2 commits intomainfrom
fix-focus-restore-in-collections
Open

fix: focus restoring in collections#9545
snowystinger wants to merge 2 commits intomainfrom
fix-focus-restore-in-collections

Conversation

@snowystinger
Copy link
Member

Closes

As an alternative to #9539

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@rspbot
Copy link

rspbot commented Jan 28, 2026

onPrimaryAction={() => tree.removeSelectedItems()}>
onPrimaryAction={() => {
tree.removeSelectedItems();
// wait for inert to clear before focusing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like users shouldn't need to do this manually? Does this mean our internal logic is not working?

Copy link
Member Author

@snowystinger snowystinger Feb 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more that we've written a possibly strange example.
It's not using an ActionBar, instead, there's an ActionGroup (its own focus scope) that is a sibling of the ListBox. Moreover, it's only rendered when there is a selection. Once the items are removed, there's no more selection, so the ActionGroup disappears immediately, before focus is restored there, and the ActionGroup doesn't restore focus, so it was just lost to the body.

It wasn't really related to the problem being solved in this PR, so I haven't given this particular issue more thought, but it should definitely be easier.

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.

3 participants