Skip to content

fix: correctly handle aria-hidden with nested shadow roots - #6411

Merged
web-padawan merged 5 commits into
mainfrom
fix/aria-hidden-deep-shadow
Aug 30, 2023
Merged

web-padawan merged 5 commits into
mainfrom
fix/aria-hidden-deep-shadow

Conversation

@web-padawan

@web-padawan web-padawan commented Aug 28, 2023 •

Copy link
Copy Markdown
Member

Description

Fixes #6410

This PR changes the logic to unwrap shadow host recursively until we get an element contained in <body>.
Original library only unwraps it once - see theKashey/aria-hidden@3dd2b66 for the implementation.

UPD: the second commit in the PR changes the above behavior to consider elements in shadow root.
This is done in order to allow aria-hidden to be set on the shadow root target's sibling elements.

Type of change

  • Bugfix


elementsToKeep.add(el);
keep(el.parentNode);
keep(el.parentNode || el.host);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change replaces the previous unwrapHost logic to ensure shadow host does not get hidden.

return;
}

[...parent.children].forEach((node) => {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This change is actually likely to cause problems as it will set aria-hidden on elements inside shadow DOM, while having no aria-hidden on the host. I'll try to find a better solution instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

UPD: added logic to keep assignedSlot - this resolves the issue with incorrect elements getting hidden.

@web-padawan
web-padawan marked this pull request as draft August 28, 2023 13:35
@web-padawan
web-padawan marked this pull request as ready for review August 28, 2023 13:56
Comment thread packages/a11y-base/src/aria-hidden.js Resolved
Co-authored-by: Sergey Vinogradov <mr.vursen@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@web-padawan
web-padawan merged commit d252b61 into main Aug 30, 2023
@web-padawan
web-padawan deleted the fix/aria-hidden-deep-shadow branch August 30, 2023 08:03
web-padawan added a commit that referenced this pull request Aug 30, 2023
…6425)

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
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.

[date-picker] Errors related to aria-hidden when date-picker is in nested shadow root

3 participants