From 783f59acaac22ac1c509a2906598fa1bfc176f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sun, 30 Aug 2026 11:09:44 +0200 Subject: [PATCH] fix(nav): open lightbox when following a search-result link apply() read the [data-open-slug] marker off the parsed doc after replaceWith() had already reparented #content (and the marker) into the live document, so openSlug came back null and the plate viewer never opened. Read it off the newContent node instead, before the swap. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_016h9VwM3YfMpDxaP8KzXcaR --- static/js/app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/static/js/app.js b/static/js/app.js index 29444e5..a784093 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -508,6 +508,9 @@ const newContent = doc.getElementById('content'); const oldContent = document.getElementById('content'); + // Read the marker off newContent — replaceWith() reparents that node into + // the live document, so `doc` no longer contains it afterwards. + const openSlug = newContent?.querySelector('[data-open-slug]')?.dataset.openSlug || null; if (newContent && oldContent) oldContent.replaceWith(newContent); const newData = doc.getElementById('roux-data'); @@ -515,8 +518,6 @@ try { POSTS = JSON.parse(newData.textContent) || []; lbBuilt = false; } catch {} } - const openSlug = doc.querySelector('[data-open-slug]')?.dataset.openSlug || null; - document.title = doc.title; syncHeadMeta(doc); if (push) history.pushState({ url: abs, slug: openSlug || undefined }, '', abs);