File tree Expand file tree Collapse file tree 5 files changed +19
-0
lines changed
Expand file tree Collapse file tree 5 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti
1818- Fixed a bug that in ` <sl-dropdown> ` that prevented tab from working properly in some cases [ #2371 ]
1919- Fixed the guard on popover to allow virtual elements [ #2399 ]
2020- Fixed the close button in ` <sl-alert> ` so clicking above/below it doesn't inadvertently close it [ #2375 ]
21+ - Fixed accessibility issues for elements that are closed while having slotted focused children. [ #2383 ]
2122
2223## 2.20.0
2324
Original file line number Diff line number Diff line change 11import { animateTo , stopAnimations } from '../../internal/animate.js' ;
2+ import { blurActiveElement } from '../../internal/closeActiveElement.js' ;
23import { classMap } from 'lit/directives/class-map.js' ;
34import { getAnimation , setDefaultAnimation } from '../../utilities/animation-registry.js' ;
45import { HasSlotController } from '../../internal/slot.js' ;
@@ -157,6 +158,7 @@ export default class SlAlert extends ShoelaceElement {
157158 this . emit ( 'sl-after-show' ) ;
158159 } else {
159160 // Hide
161+ blurActiveElement ( this ) ;
160162 this . emit ( 'sl-hide' ) ;
161163
162164 clearTimeout ( this . autoHideTimeout ) ;
Original file line number Diff line number Diff line change 11import { animateTo , stopAnimations } from '../../internal/animate.js' ;
2+ import { blurActiveElement } from '../../internal/closeActiveElement.js' ;
23import { classMap } from 'lit/directives/class-map.js' ;
34import { getAnimation , setDefaultAnimation } from '../../utilities/animation-registry.js' ;
45import { HasSlotController } from '../../internal/slot.js' ;
@@ -208,6 +209,7 @@ export default class SlDialog extends ShoelaceElement {
208209 this . emit ( 'sl-after-show' ) ;
209210 } else {
210211 // Hide
212+ blurActiveElement ( this ) ;
211213 this . emit ( 'sl-hide' ) ;
212214 this . removeOpenListeners ( ) ;
213215 this . modal . deactivate ( ) ;
Original file line number Diff line number Diff line change 11import { animateTo , stopAnimations } from '../../internal/animate.js' ;
2+ import { blurActiveElement } from '../../internal/closeActiveElement.js' ;
23import { classMap } from 'lit/directives/class-map.js' ;
34import { getAnimation , setDefaultAnimation } from '../../utilities/animation-registry.js' ;
45import { HasSlotController } from '../../internal/slot.js' ;
@@ -237,6 +238,7 @@ export default class SlDrawer extends ShoelaceElement {
237238 this . emit ( 'sl-after-show' ) ;
238239 } else {
239240 // Hide
241+ blurActiveElement ( this ) ;
240242 this . emit ( 'sl-hide' ) ;
241243 this . removeOpenListeners ( ) ;
242244
Original file line number Diff line number Diff line change 1+ /**
2+ * Calls the blur method on the current active element if it is a child of the provided element.
3+ * Needed for fixing a11y errors in console.
4+ * @see https://github.com/shoelace-style/shoelace/issues/2283
5+ * @param elm The element to check
6+ */
7+ export const blurActiveElement = ( elm : HTMLElement ) => {
8+ const { activeElement } = document ;
9+ if ( activeElement && elm . contains ( activeElement ) ) {
10+ ( document . activeElement as HTMLElement ) ?. blur ( ) ;
11+ }
12+ } ;
You can’t perform that action at this time.
0 commit comments