Merge branch 'schilchSICKAG-fix/a11y-errors-for-blur' into next

next
Cory LaViska 2025-03-11 13:30:34 -04:00
commit 5be95408a5
5 zmienionych plików z 19 dodań i 0 usunięć

Wyświetl plik

@ -18,6 +18,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti
- Fixed a bug that in `<sl-dropdown>` that prevented tab from working properly in some cases [#2371]
- Fixed the guard on popover to allow virtual elements [#2399]
- Fixed the close button in `<sl-alert>` so clicking above/below it doesn't inadvertently close it [#2375]
- Fixed accessibility issues for elements that are closed while having slotted focused children. [#2383]
## 2.20.0

Wyświetl plik

@ -1,4 +1,5 @@
import { animateTo, stopAnimations } from '../../internal/animate.js';
import { blurActiveElement } from '../../internal/closeActiveElement.js';
import { classMap } from 'lit/directives/class-map.js';
import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry.js';
import { HasSlotController } from '../../internal/slot.js';
@ -157,6 +158,7 @@ export default class SlAlert extends ShoelaceElement {
this.emit('sl-after-show');
} else {
// Hide
blurActiveElement(this);
this.emit('sl-hide');
clearTimeout(this.autoHideTimeout);

Wyświetl plik

@ -1,4 +1,5 @@
import { animateTo, stopAnimations } from '../../internal/animate.js';
import { blurActiveElement } from '../../internal/closeActiveElement.js';
import { classMap } from 'lit/directives/class-map.js';
import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry.js';
import { HasSlotController } from '../../internal/slot.js';
@ -208,6 +209,7 @@ export default class SlDialog extends ShoelaceElement {
this.emit('sl-after-show');
} else {
// Hide
blurActiveElement(this);
this.emit('sl-hide');
this.removeOpenListeners();
this.modal.deactivate();

Wyświetl plik

@ -1,4 +1,5 @@
import { animateTo, stopAnimations } from '../../internal/animate.js';
import { blurActiveElement } from '../../internal/closeActiveElement.js';
import { classMap } from 'lit/directives/class-map.js';
import { getAnimation, setDefaultAnimation } from '../../utilities/animation-registry.js';
import { HasSlotController } from '../../internal/slot.js';
@ -237,6 +238,7 @@ export default class SlDrawer extends ShoelaceElement {
this.emit('sl-after-show');
} else {
// Hide
blurActiveElement(this);
this.emit('sl-hide');
this.removeOpenListeners();

Wyświetl plik

@ -0,0 +1,12 @@
/**
* Calls the blur method on the current active element if it is a child of the provided element.
* Needed for fixing a11y errors in console.
* @see https://github.com/shoelace-style/shoelace/issues/2283
* @param elm The element to check
*/
export const blurActiveElement = (elm: HTMLElement) => {
const { activeElement } = document;
if (activeElement && elm.contains(activeElement)) {
(document.activeElement as HTMLElement)?.blur();
}
};