Skip to content

fix: skip visibility check in Focusable and Pressable dev warnings - #10547

Open
SimenB wants to merge 1 commit into
adobe:mainfrom
SimenB:fix-focusable-hidden-warning
Open

fix: skip visibility check in Focusable and Pressable dev warnings#10547
SimenB wants to merge 1 commit into
adobe:mainfrom
SimenB:fix-focusable-hidden-warning

Conversation

@SimenB

@SimenB SimenB commented Sep 1, 2026

Copy link
Copy Markdown

📖 Summary

The dev-only mount check in Focusable and Pressable asks whether tabIndex reached the DOM child, but isFocusable also walks ancestors for visibility. A correct child mounted inside a hidden subtree - e.g. a collapsed DisclosurePanel - warned even though tabIndex was applied.

Both call sites now pass {skipVisibilityCheck: true}, as the tree walk in interactions/utils.ts already does. matches() still catches a child that drops its props, and the other two checks in the effect are untouched.

Closes #10546

✅ 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). — tests added; no storybook, dev-mode warning with no visual surface.
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component). — none needed.
  • Looked at the Accessibility Practices for this feature - Aria Practices - dev warning only, no behaviour change.
  • I understand every change in this PR and can explain why it's there.
  • If AI-assisted, I followed our AI contribution guidance and pointed my assistant at CLAUDE.md. - AI-assisted; I reviewed every line and tested the result in our own repository to see the warning no longer prints.

📝 Test Instructions:

yarn jest packages/react-aria/test/interactions/Focusable.test.js packages/react-aria/test/interactions/Pressable.test.js

One test per file: a correct child inside <div hidden> must not warn. Both fail on main and pass with this change. The existing "child is not focusable" tests are unchanged and still pass.

🧢 Your Project:

N/A

@SimenB

SimenB commented Sep 1, 2026

Copy link
Copy Markdown
Author

I've signed the CLA (I think 😀)

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this seems like the right approach

@yihuiliao yihuiliao closed this Sep 2, 2026
@yihuiliao yihuiliao reopened this Sep 2, 2026
@yihuiliao

Copy link
Copy Markdown
Member

Just fyi, we are in a sort of merge freeze right now but will merge it later

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<Focusable>/<Pressable> dev warning "child must be focusable" false-positives for content mounted in hidden subtrees

3 participants