Skip to content

fix(docs): repair broken Ctrl+K search - #91

Merged
vito merged 1 commit into
mainfrom
fix-search-insertbefore
Jun 4, 2026
Merged

vito merged 1 commit into
mainfrom
fix-search-insertbefore

Conversation

@vito

@vito vito commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Problem

Docs search was completely broken — the browser console showed:

Uncaught DOMException: Node.insertBefore: Child to insert before is not a child of this node
    search.js:90

Root cause

docs/js/search.js inserted the search trigger with:

sidebar.insertBefore(trigger, brand.nextSibling);

But .brand is nested inside .sidebar-head (docs/html/page.tmpl), not directly under nav.sidebar. So brand.nextSibling is the toggle <label> — a child of .sidebar-head, not of sidebar — and insertBefore rejects it. The thrown exception aborted the search IIFE, disabling Ctrl+K / search entirely.

Fix

Anchor the insert to a real child of sidebar, the .sidebar-nav div, placing the trigger just above the nav links, with an appendChild fallback if it's absent.

🤖 Generated with Claude Code

`.brand` is nested inside `.sidebar-head`, so `brand.nextSibling` is not a
child of `nav.sidebar`. Calling `sidebar.insertBefore(trigger,
brand.nextSibling)` threw "Child to insert before is not a child of this
node", aborting the search IIFE and breaking Ctrl+K search entirely.

Anchor the insert to `.sidebar-nav` instead, placing the trigger above the
nav list, with an appendChild fallback.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying dang with  Cloudflare Pages  Cloudflare Pages

Latest commit: 819876b
Status: ✅  Deploy successful!
Preview URL: https://731b7284.dang-3kk.pages.dev
Branch Preview URL: https://fix-search-insertbefore.dang-3kk.pages.dev

View logs

@vito
vito merged commit e624175 into main Jun 4, 2026
6 checks passed
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.

1 participant