You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Docs search stops working after navigating via search result (View Transitions) #712
The docs website search breaks after navigating to a search result. On first page load, clicking the search textbox works — the user can type and search. After clicking a search result (which triggers an Astro View Transition), the search textbox can no longer be focused or typed into. The only workaround is a hard refresh (Ctrl+F5).
Click on any search result to navigate to that page
Try to click the search button again or press Ctrl+K
Expected: Search modal opens and the input is focused
Actual: Nothing happens — search is completely non-functional
Root Cause
The Search.astro component uses a <script define:vars> block that captures DOM element references (searchBtn, searchModal, searchInput, etc.) and attaches event listeners once at initial script execution time.
The docs site uses Astro View Transitions (<ViewTransitions /> in BaseLayout.astro). After a client-side navigation, Astro swaps the DOM — replacing all the elements. The old JavaScript references now point to detached DOM nodes, so clicks/keyboard shortcuts silently do nothing.
Other components in the docs site (theme toggle, copy buttons) already handle this correctly by using document.addEventListener('astro:page-load', initFunction), but the search component was missing this pattern.
Environment
Astro 5.x with View Transitions enabled
Pagefind search integration
All browsers affected (View Transitions are the root cause, not browser-specific)
Activity
fix(docs): re-initialize search after Astro View Transitions
diberry commentedon Mar 31, 2026
🔄 Ralph status: PR #713 addresses this. Clean mergeable state, 2 files, 2 Playwright regression tests. Ready for review.
diberry commentedon Mar 31, 2026
✅ Status Update — Issue #712
PR #713 addresses this issue (external contributor: @CarlosSardo):
Ready for merge.
fix(docs): re-initialize search after Astro View Transitions
fix(docs): re-initialize search after Astro View Transitions
fix(docs): re-initialize search after Astro View Transitions
fix(docs): re-initialize search after Astro View Transitions
fix(docs): re-initialize search after Astro View Transitions (#856)
fix(docs): re-initialize search after Astro View Transitions (#712)
fix(docs): re-initialize search after Astro View Transitions (#712) (#…
fix(docs): re-initialize search after Astro View Transitions
fix(docs): re-initialize search after Astro View Transitions (#856)
fix(docs): re-initialize search after Astro View Transitions (#712) (#…