Skip to content

Commit 47e6a72

Browse files
Copilottrivikr
andcommitted
fix(search): cancel pending rAF on stop and populate cache synchronously on start (#7)
Co-authored-by: trivikr <16024985+trivikr@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 364626e commit 47e6a72

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/pages/search.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ function scheduleFocusableElementsRefresh() {
443443
function stopObservingFocusableElements() {
444444
focusableElementsObserver?.disconnect()
445445
focusableElementsObserver = null
446+
if (refreshFocusableElementsFrame != null) {
447+
window.cancelAnimationFrame(refreshFocusableElementsFrame)
448+
refreshFocusableElementsFrame = null
449+
}
446450
focusableElements.value = []
447451
}
448452
@@ -463,6 +467,9 @@ function startObservingFocusableElements() {
463467
attributeFilter: ['class', 'style', 'hidden', 'aria-hidden'],
464468
})
465469
470+
// Perform an initial synchronous refresh so focusableElements is populated
471+
// before any immediate key handling (ArrowUp/ArrowDown) occurs.
472+
refreshFocusableElements()
466473
scheduleFocusableElementsRefresh()
467474
}
468475

0 commit comments

Comments
 (0)