this repo has no description
1export default function focusNode(
2 node: HTMLElement,
3 focusedIndex: number | null,
4) {
5 const nodeIndex = Number(node.getAttribute('data-index'));
6
7 // Handle the initial focus when applicable
8 if (nodeIndex === focusedIndex) {
9 node.focus();
10 }
11
12 return {
13 update(newFocusedIndex) {
14 if (nodeIndex === newFocusedIndex) {
15 node.focus();
16 }
17 },
18 };
19}