import type React from 'react'; import type { VirtuosoHandle } from 'react-virtuoso'; const selectChild = (index: number, handle: React.RefObject, node: ParentNode = document) => { const selector = `[data-index="${index}"] .focusable`; const element = node.querySelector(selector); if (element) { element.focus({ preventScroll: false }); } else { handle.current?.scrollIntoView({ index, behavior: 'smooth', done: () => { if (!element) document.querySelector(selector)?.focus(); }, }); } }; export { selectChild };