Skip to content

Accessibility: aria-hidden on focusable expand/collapse button in entity tree #100

@JohnRDOrazio

Description

@JohnRDOrazio

Problem

Chrome DevTools reports an accessibility warning:

Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users.

The expand/collapse chevron button in EntityTreeNode has both tabIndex={-1} and aria-hidden="true". While tabIndex={-1} removes it from the tab order, the element is still a <button> and can receive focus programmatically (e.g. via click). When focused, the browser flags the aria-hidden conflict.

Location

components/editor/shared/EntityTreeNode.tsx:206-211:

<button
  onClick={handleToggle}
  className="w-4 h-4 flex items-center justify-center flex-shrink-0"
  tabIndex={-1}
  aria-hidden="true"
>

Fix

Replace the <button> with a non-focusable <span> using role="presentation" since the parent <li> row already handles selection and keyboard navigation:

<span
  role="presentation"
  onClick={handleToggle}
  className="w-4 h-4 flex items-center justify-center flex-shrink-0 cursor-pointer"
>

This eliminates the focus/aria-hidden conflict while preserving the click behavior for mouse users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions