carbon-design-system / ibm-products

A Carbon-powered React component library for IBM Products
https://carbon-for-ibm-products.netlify.app/
Apache License 2.0
83 stars 116 forks source link

[a11y]: SidePanel and Tearsheet components don't return focus to triggering element on close #5014

Open Sam-Wool opened 2 weeks ago

Sam-Wool commented 2 weeks ago

Package

@carbon/ibm-products

Browser

Chrome, Firefox

Operating System

Windows

Package version

v2.35.0

React version

No response

Automated testing tool and ruleset

IBM Accessibility Requirements

Assistive technology

No response

Description

When closing a SidePanel or Tearsheet, focus isn't returned to the element which triggered opening the dialog, and there is no way to choose an element to return focus to in the component API.

WCAG 2.1 Violation

2.4.3 Focus Order: https://www.ibm.com/able/requirements/requirements/#2_4_3

Reproduction/example

https://codesandbox.io/p/devbox/great-architecture-hec6vl?file=%2Fsrc%2FExample%2FExample.jsx

Steps to reproduce

Open the SidePanel via the button, and then close it. Notice that focus isn't returned to the button. The same behavior can be seen on the Tearsheet codesandbox (https://codesandbox.io/p/devbox/silly-euler-3q1l14?file=%2Fsrc%2FExample%2FExample.jsx).

Compare this to the Carbon 11 Modal (see https://react.carbondesignsystem.com/?path=/docs/components-modal--overview), which returns focus to the button on close. Note that this is accomplished by the prop launcherButtonRef, which allows a user to specify a ref to return focus to once the dialog is closed.

Code of Conduct