Skip to content

Conversation

@SubZtep
Copy link

@SubZtep SubZtep commented Nov 23, 2025

Summary

  • Exposes activeId property from FocusContext in useFocusManager hook to get the id of the currently focused component
  • Returns undefined when no component has focus
  • Added test coverage for the new property
  • Updated documentation in root readme

Use case

This allows components to programmatically check which component currently has focus without needing to track focus state manually. Useful for displaying focus state in UI or conditionally rendering based on what's focused.

Test plan

  • Added new test "the focus helper reports whichever id currently holds focus" in test/focus.tsx
  • Test verifies that activeId is defined when a component is focused
  • Test verifies that activeId becomes undefined when focus is cleared with Esc key

@sindresorhus
Copy link
Collaborator

I don't review AI generated PRs, so you will have to find someone to review this.

@SubZtep
Copy link
Author

SubZtep commented Nov 23, 2025

I don't review AI generated PRs, so you will have to find someone to review this.

The main change is only one line insert. The PR text is really based on an AI suggestion, but I think it make sense tho. Not sure who should I find. :finnadie:

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.

2 participants