Skip to content

fix: resolve aria-hidden focusable descendants accessibility violation#41

Open
LorenzoGalassi wants to merge 1 commit intoawran5:mainfrom
LorenzoGalassi:fix/aria-hidden-focusable-descendants
Open

fix: resolve aria-hidden focusable descendants accessibility violation#41
LorenzoGalassi wants to merge 1 commit intoawran5:mainfrom
LorenzoGalassi:fix/aria-hidden-focusable-descendants

Conversation

@LorenzoGalassi
Copy link
Copy Markdown

Problem

The chat box container has aria-hidden hardcoded to 'true' at all times, even when the chat is open. When the chat is closed, the <input> and <button> elements inside the container remain focusable via keyboard, which violates WCAG 2.1 — 4.1.2 Name, Role, Value and triggers a Lighthouse/axe error:

`[aria-hidden="true"] elements must not contain focusable descendants`

Additionally, the open/close button div has aria-hidden='true' making it completely invisible to assistive technologies, and lacks keyboard support (role, tabIndex, keyboard handler).

Fix

Chat box container:

  • Toggle aria-hidden based on isOpen state instead of hardcoding true
  • Add the inert attribute when closed — this removes all descendants from the tab order and assistive technology tree without affecting the CSS height transition animation. inert is now baseline across all modern browsers.

Open button & close button (div elements acting as buttons):

  • Remove aria-hidden='true'
  • Add role="button", tabIndex={0}, aria-label, and onKeyDown handler so they are reachable and operable via keyboard and screen readers

Testing

Verified with Lighthouse accessibility audit — the [aria-hidden="true"] elements must not contain focusable descendants violation is resolved after this change.

The chat box container had aria-hidden hardcoded to 'true' regardless
of open/close state, while containing focusable <input> and <button>
elements. This caused an axe/Lighthouse accessibility violation:
"[aria-hidden=true] elements must not contain focusable descendants".

Changes:
- Chat box: toggle aria-hidden based on isOpen state
- Chat box: add inert attribute when closed to fully remove descendants
  from tab order and assistive technology tree
- Open button: replace aria-hidden='true' with role, tabIndex, aria-label
  and keyboard handler so it is reachable by keyboard and screen readers
- Close button: same treatment as open button

Fixes accessibility score regression reported by Lighthouse/PageSpeed.
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.

1 participant