fix(docs): re-initialize search after Astro View Transitions#856
fix(docs): re-initialize search after Astro View Transitions#856
Conversation
🟢 Impact Analysis — PR #856Risk tier: 🟢 LOW 📊 Summary
🎯 Risk Factors
📦 Modules Affecteddocs (2 files)
This report is generated automatically for every PR. See #733 for details. |
🛫 PR Readiness Check
PR Scope: 🔧 Infrastructure
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 3 commits — consider squashing before review |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | No source files changed — changeset not required |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ❌ | Copilot threads resolved | 2 unresolved Copilot thread(s) — fix and resolve before merging |
| ❌ | CI passing | 4 check(s) still running |
Files Changed (2 files, +149 −43)
| File | +/− |
|---|---|
docs/src/components/Search.astro |
+78 −43 |
docs/tests/search.spec.mjs |
+71 −0 |
Total: +149 −43
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
There was a problem hiding this comment.
Pull request overview
This PR cherry-picks the docs-site fix from #713 to keep Pagefind search working after Astro View Transitions by re-initializing DOM references and event handlers after client-side navigation.
Changes:
- Refactors
Search.astroto (re)bind DOM lookups and listeners via aninitSearch()run onastro:page-load. - Adds Playwright regression coverage to ensure search continues working after navigating via a search result (View Transition).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| docs/src/components/Search.astro | Re-initializes search DOM refs/listeners after View Transitions; ensures Pagefind instance persists across navigations. |
| docs/tests/search.spec.mjs | Adds regression tests validating search still opens/works after View Transition navigation. |
77493c1 to
b96ea74
Compare
33414a3 to
f296ff4
Compare
Fixes #712 — docs site search becomes non-functional after navigating via Astro View Transitions. Re-initializes DOM element references via the astro:page-load event, which fires on initial load and after each client-side View Transition. Event listeners are properly torn down and re-attached to fresh DOM references. Includes 2 Playwright regression tests for post-navigation search behavior: - Search works after navigating via search result - Ctrl+K opens search after View Transition navigation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f296ff4 to
9649e24
Compare
tamirdresher
left a comment
There was a problem hiding this comment.
Approved by @tamirdresher — reviewed diff, CI green, changes are clean and well-tested. cc @diberry
Fixes #712 — docs site search becomes non-functional after navigating via Astro View Transitions. Re-initializes DOM element references via the astro:page-load event, which fires on initial load and after each client-side View Transition. Event listeners are properly torn down and re-attached to fresh DOM references. Includes 2 Playwright regression tests for post-navigation search behavior: - Search works after navigating via search result - Ctrl+K opens search after View Transition navigation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cherry-picks the fix from #713. Re-initializes PageFind search after Astro View Transitions so search works after navigation.
Original author: @CarlosSardo
Closes #712
Part of stale PR triage (diberry#137)