feat: improve/refactor focus handling (#17796)

* feat: improve focus

* test

* lint

* use modulus in loop
This commit is contained in:
Min Idzelis 2025-04-30 00:19:38 -04:00 committed by GitHub
parent 2e8a286540
commit 4b1ced439b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 92 additions and 129 deletions

View file

@ -1,6 +1,7 @@
<script lang="ts">
import { t } from 'svelte-i18n';
import Button from './button.svelte';
import { getTabbable } from '$lib/utils/focus-util';
interface Props {
/**
@ -23,7 +24,12 @@
const moveFocus = () => {
const targetEl = document.querySelector<HTMLElement>(target);
targetEl?.focus();
if (targetEl) {
const element = getTabbable(targetEl)[0];
if (element) {
element.focus();
}
}
};
const getBreakpoint = () => {