-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
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, []); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Test results for "tests 1"7 flaky39449 passed, 823 skipped Merge workflow run. |
Closes #36296