/** * Svelte action: autofocus an element on mount. * Usage: */ export function autofocus(node) { // Use requestAnimationFrame to ensure DOM is settled requestAnimationFrame(() => { node.focus() // On mobile, also try after a slight delay for virtual keyboard if ('ontouchstart' in window) { setTimeout(() => node.focus(), 100) } }) }