Skip to content

fix: use attribute presence check for data-react-aria-top-layer in MutationObserver#9763

Open
lixiaoyan wants to merge 1 commit intoadobe:mainfrom
lixiaoyan:fix/aria-hide-outside-top-layer-check
Open

fix: use attribute presence check for data-react-aria-top-layer in MutationObserver#9763
lixiaoyan wants to merge 1 commit intoadobe:mainfrom
lixiaoyan:fix/aria-hide-outside-top-layer-check

Conversation

@lixiaoyan
Copy link
Contributor

@lixiaoyan lixiaoyan commented Mar 9, 2026

Closes #9762

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

  1. Call ariaHideOutside on some target elements
  2. Dynamically insert a new element with data-react-aria-top-layer="" (empty string) into the DOM
  3. Verify the MutationObserver correctly recognizes it as a visible node and does not hide it with aria-hidden="true"
  4. Compare with the previous behavior where only data-react-aria-top-layer="true" (exact string) was recognized

What changed

In ariaHideOutside.ts, the initial DOM scan uses a CSS attribute presence selector ([data-react-aria-top-layer]) which matches the attribute regardless of value, but the MutationObserver previously checked node.dataset.reactAriaTopLayer === 'true', requiring an exact match.

This PR:

  • Extracts the check into a reusable isAlwaysVisibleNode function
  • Changes the data-react-aria-top-layer check to !== undefined (attribute presence) to match the initial scan behavior
  • Keeps data-live-announcer === 'true' unchanged since it is always set to "true" in LiveAnnouncer.tsx

🧢 Your Project:

N/A

…tationObserver

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the RAC label Mar 9, 2026
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.

ariaHideOutside: inconsistent attribute check between initial scan and MutationObserver

1 participant