How to setFocus on modal close button

475
1
12-29-2022 10:01 AM
GregoryBologna
Occasional Contributor II

This seems to have broken in beta 99. The "X" button is getting focus.

GregoryBologna_0-1672336742696.png

beta 97

Sets focus on the component. By default, tries to focus on focusable content. If there is none, it will focus on the close button. To focus on the close button, use the close-button focus ID.

 

let button = document.createElement('calcite-button');
button.setAttribute('slot', 'secondary');     
button.innerHTML = 'Cancel'; 

??? not working
button.setFocus('close-button');

 

0 Kudos
1 Reply
BenElan
Esri Contributor

Hi @GregoryBologna ,

This change was intentional  to align with a11y standards, you can read more in this comment: https://github.com/Esri/calcite-components/issues/5856#issuecomment-1333941884

We are working on updating all of the documentation to align with the pre-v1 breaking changes, sorry for the confusion! The documentation currently represents beta.97 functionality. The documentation will be up to date for the upcoming v1 release, and I'll comment here if we get it up to date for beta.99 before then.

Happy holidays!

0 Kudos