kopia lustrzana https://github.com/shoelace-style/shoelace
Force the focus-visible style for slider handles if the keyboard is used to move them, even if they were originally focused via the mouse cursor
rodzic
6686f3397b
commit
f6cfdb2f09
|
@ -297,6 +297,8 @@ export default class SlMultiRange extends ShoelaceElement {
|
|||
return;
|
||||
}
|
||||
|
||||
this.baseDiv.classList.add('keyboard-focus');
|
||||
|
||||
if (value !== this.#sliderValues.get(sliderId)) {
|
||||
this.#moveHandle(handle, value);
|
||||
|
||||
|
@ -331,14 +333,13 @@ export default class SlMultiRange extends ShoelaceElement {
|
|||
|
||||
#onFocus(): void {
|
||||
if (this.#hasFocus) return;
|
||||
console.info('sl-focus');
|
||||
this.emit('sl-focus');
|
||||
this.#hasFocus = true;
|
||||
}
|
||||
|
||||
#onBlur(event: FocusEvent): void {
|
||||
this.baseDiv?.classList?.remove('keyboard-focus');
|
||||
if (event.relatedTarget && this.shadowRoot?.contains(event.relatedTarget as Node)) return;
|
||||
console.info('sl-blur');
|
||||
this.emit('sl-blur');
|
||||
this.#hasFocus = false;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ export default css`
|
|||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.handle:focus-visible {
|
||||
.handle:focus-visible, .keyboard-focus .handle:focus {
|
||||
outline: var(--sl-focus-ring);
|
||||
outline-offset: var(--sl-focus-ring-offset);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue