File size: 243 Bytes
a5619c2
 
28faefd
 
 
 
 
 
 
 
 
 
 
7f214aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { tick } from "svelte";

export function autofocus(node: HTMLElement, enabled = true) {
	function update(enabled = true) {
		if (enabled) {
			tick().then(() => {
				node.focus();
			});
		}
	}
	update(enabled);

	return { update };
}