Skip to content

[WIP]: fix: global focus event listeners#9665

Closed
snowystinger wants to merge 2 commits intomainfrom
lint-rule-for-global-focus-events
Closed

[WIP]: fix: global focus event listeners#9665
snowystinger wants to merge 2 commits intomainfrom
lint-rule-for-global-focus-events

Conversation

@snowystinger
Copy link
Member

Closes

Started from #9632

Realised we cannot only listen to focus events for certain managers at the global document/window level. Focus events don't bubble past their respective rootNode. So we would miss a lot of events possibly.

I've started some of the fixes, but this will need more work. I'm putting it in our backlog.

I've fixed "preventFocus".

useLandmark will need some attention, we'll need to add a Map<Node, number> and any landmark we add, we'll need to add listeners to every rootNode of that landmark. We'll increase the refCount in the map at that time. We'll need to make sure that for focus events that go across these rootNode boundaries, that we handle that correctly, likely by calling stopPropagation at the lowest handler. That or we'll need to handle it at the lowest root which contains both the related (blurred) target and the new focused target. I'm not sure which yet.

useViewportSize is an interesting one, it fixes an iOS bug and it doesn't have any information about a target element. We may be able to turn off the rule entirely for this file, but if so, we should include a code comment explaining why

DragManager will need updating, we'll need to move the setup of events until after this.updateValidDropTargets probably. This way we can make a list of all the rootNodes that we need to listen to as it will be any that contain the valid drop targets.

✅ 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:

@github-actions github-actions bot added the RAC label Feb 16, 2026
@snowystinger
Copy link
Member Author

Closing, this is meant as a starting point and is linked to from the ticket for further shadow dom work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant