Skip to content

fix(search): cancel pending rAF on stop and populate cache synchronously on start#7

Merged
trivikr merged 2 commits into
get-focusable-elementsfrom
copilot/sub-pr-6
Mar 25, 2026
Merged

fix(search): cancel pending rAF on stop and populate cache synchronously on start#7
trivikr merged 2 commits into
get-focusable-elementsfrom
copilot/sub-pr-6

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 25, 2026

Two correctness gaps in the keyboard navigation focus cache lifecycle introduced by the MutationObserver/rAF caching layer.

Changes

  • stopObservingFocusableElements() — cancel any in-flight requestAnimationFrame before clearing the cache; previously a pending rAF could fire after stop and briefly repopulate focusableElements
  • startObservingFocusableElements() — call refreshFocusableElements() synchronously after attaching the observer so the cache is ready before the first keypress; the rAF-scheduled refresh is kept for coalescing subsequent mutation callbacks
function stopObservingFocusableElements() {
  focusableElementsObserver?.disconnect()
  focusableElementsObserver = null
  if (refreshFocusableElementsFrame != null) {
    window.cancelAnimationFrame(refreshFocusableElementsFrame)
    refreshFocusableElementsFrame = null
  }
  focusableElements.value = []
}

// in startObservingFocusableElements(), after observer.observe(...)
refreshFocusableElements()       // immediate — first keypress won't see empty cache
scheduleFocusableElementsRefresh() // rAF — coalesces subsequent mutations

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Update search keyboard navigation to use cached focus targets fix(search): cancel pending rAF on stop and populate cache synchronously on start Mar 25, 2026
Copilot AI requested a review from trivikr March 25, 2026 14:52
@trivikr trivikr marked this pull request as ready for review March 25, 2026 14:56
@trivikr trivikr merged commit 5c2d673 into get-focusable-elements Mar 25, 2026
4 checks passed
@trivikr trivikr deleted the copilot/sub-pr-6 branch March 25, 2026 14:59
trivikr added a commit that referenced this pull request Apr 12, 2026
…sly 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>
trivikr added a commit that referenced this pull request Apr 17, 2026
…sly 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants