Skip to content

fix(aria): skip text nodes that are not rendered - #42982

Closed
Yuriy Mikityuk (yuriy-mikityuk) wants to merge 1 commit into
microsoft:mainfrom
yuriy-mikityuk:fix-aria-unrendered-text
Closed

Yuriy Mikityuk (yuriy-mikityuk) wants to merge 1 commit into
microsoft:mainfrom
yuriy-mikityuk:fix-aria-unrendered-text

Conversation

@yuriy-mikityuk

Copy link
Copy Markdown
Contributor

Two cases where text isn't rendered but still ends up in aria snapshots and accessible names:

<div role=button>Light</div>
<script>
  document.querySelector('div').attachShadow({ mode: 'open' }).innerHTML = 'Shadow';
</script>

<details>
  <summary>Summary</summary>
  Details
</details>

"Light" is not assigned to any slot, so the button is named "Shadow" in Chromium's accessibility tree, but Playwright named it "LightShadow" and getByRole('button', { name: 'Shadow', exact: true }) found nothing. "Details" sits directly inside a closed details, and the snapshot showed - group: Summary Details, same as for an open one.

Unslotted elements are already treated as hidden, but text nodes were only checked through their parent, which is visible in both cases. Added isTextNodeHiddenForAria and used it in the aria snapshot and in the accessible name computation.

Light dom text of a shadow host that is not assigned to a slot, and text
directly inside a closed details, are not rendered. Playwright only checked
the visibility of the parent element, so this text leaked into aria
snapshots and accessible names. For example, a web component with
unslotted "Light" text and "Shadow" in its shadow root got the name
"LightShadow" instead of "Shadow".
@dgozman

Copy link
Copy Markdown
Collaborator

Yuriy Mikityuk (@yuriy-mikityuk) Please start with filing an issue, according to the contributing guide.

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