[a11y]: Tearsheet selectorPrimaryFocus broken #5152
Labels
component: Tearsheet
Sev 3
Visible or noticeable to users but does not impede functionality. Has a workaround.
type: a11y ♿
Issues not following accessibility standards
type: bug 🐛
Something isn't working
Package
@carbon/ibm-products
Browser
Chrome
Operating System
MacOS
Package version
v2.37.0
React version
v18
Automated testing tool and ruleset
manual tests and jest tests
Assistive technology
no
Description
selectorPrimaryFocus
is broken with the latest @carbon/ibm-products. It regressed somewhere between 2.15 and 2.37. (It was working in 2.15 except for #3988.)ComposedModal.js correctly sets focus to the element specified by
selectorPrimaryFocus
.But immediately after that,
TearsheetShell
'shandleStackChange.claimFocus()
code moves focus to the first element, i.e. to the Tearsheet’s close button.TearsheetShell.js also has some other code in
useEffect()
to do that.All this code breaks the work done by ComposedModal.js.
WCAG 2.1 Violation
No response
Reproduction/example
https://codesandbox.io/p/live/7215b329-7aa2-4c32-8858-cb36287ce0efhttps://codesandbox.io/p/devbox/tearsheet-example-wrq59h
Steps to reproduce
Just click the "open tearsheet" button and watch where focus goes. It should go to the
<a>
but it goes to the close button instead.The key facets of the test case are:
hasCloseIcon={true}
- This makes the first focusable element the close icon.selectorPrimaryFocus="a"
- This tells Tearsheet that it should focus the<a>
instead of the close icon.Focus should go <a href="#">here</a>
Code of Conduct
The text was updated successfully, but these errors were encountered: