From 206db935872f5ebfd305fc120ae45f63707b1e4d Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 17 Aug 2026 14:14:33 -0400 Subject: [PATCH] =?UTF-8?q?fix(reader):=20PDF=20contents=20drawer=20render?= =?UTF-8?q?ed=20nothing=20=E2=80=94=20duplicate=20x-for=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Diagnosed in a real browser (playwright/chromium against the running app + Head First SQL): the engine's book.toc held all 18 entries with correct labels/hrefs and the tab counter even showed 380, yet zero links rendered while the console flooded with 'Alpine Warning: Duplicate key on x-for'. Root cause: the drawer keyed TOC rows by item.href. PDF outline entries frequently share the same destination (e.g. the printed TOC page is targeted by several bookmark entries), so flattened items carried duplicate keys — and Alpine's x-for renders NOTHING for a duplicated key, not even the unique ones. EPUB TOCs never collided because their hrefs are unique file paths, which is why this only surfaced on PDFs. Key is now href + row index (the list is static once loaded, so positional keys are safe). Verified end-to-end in the browser: 18 entries render and the drawer populates. --- templates/reader.templ | 5 ++++- templates/reader_templ.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/templates/reader.templ b/templates/reader.templ index 3dec0b8..eac8cce 100644 --- a/templates/reader.templ +++ b/templates/reader.templ @@ -533,7 +533,10 @@ templ ReaderTOCDrawer() {