Skip to content

fix(aria): process children of hidden elements #36316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Jun 16, 2025

Closes #36296

@Skn0tt Skn0tt requested a review from Copilot June 16, 2025 08:05
@Skn0tt Skn0tt self-assigned this Jun 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses processing of hidden elements for ARIA snapshots in response to issue #36296. Key changes include:

  • Adding a new test to verify that visible children of hidden elements are correctly captured.
  • Introducing the helper function isVisible in the ARIA snapshot generation, and modifying text node and element handling accordingly.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/page/page-aria-snapshot.spec.ts Adds a test verifying that visible children within hidden elements are processed.
packages/injected/src/ariaSnapshot.ts Introduces a new isVisible helper function and updates element processing logic to incorporate it.
Comments suppressed due to low confidence (2)

packages/injected/src/ariaSnapshot.ts:50

  • Consider adding a brief comment above the isVisible function to explain its purpose in determining element visibility for ARIA processing.
function isVisible(element: Element, options?: { forAI?: boolean }): boolean {

tests/page/page-aria-snapshot.spec.ts:662

  • [nitpick] For consistency with other test names, consider renaming the test title to begin with 'should', for example: "should show visible children of hidden elements".
it('show visible children of hidden elements', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/36296' }  }, async ({ page }) => {

This comment has been minimized.

if (!isVisible)
if (!isVisible(element, options)) {
// skip this element, but still process its children: https://github.com/w3c/aria/issues/1055
processElement(ariaNode, element, []);
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure how this makes sense. Also, you can't process children as if they are visible. And we probably only want this for non-aria visibility.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure how this makes sense

How so? As in, you're surprised how Chromium and this issue interpret the ARIA spec, or as in this code is weird?

Also, you can't process children as if they are visible.

I think we can, because the isVisible method takes parent elements into account when determining visibility.

we probably only want this for non-aria visibility.

It already does so, based on my reading of isElementHiddenForAria. I added a test in 9775c4a to ensure that.

Copy link
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-library] › library/chromium/oopif.spec.ts:284:3 › should click @chromium-ubuntu-22.04-node18
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:986:7 › cli codegen › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node18-1
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node22-1
⚠️ [webkit-library] › library/screenshot.spec.ts:66:14 › page screenshot › should work with a mobile viewport and fullPage @webkit-ubuntu-22.04-node18
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

39449 passed, 823 skipped
✔️✔️✔️

Merge workflow run.

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.

[Bug]: ariaSnapshot hides visibility: visible inside visibility: hidden
2 participants