fix(doc): restore PDF link clicks after pdf.js 6 upgrade#1694
Merged
Conversation
pdfjs-dist 6 inserts its page layers earlier in the render lifecycle than v4 did, so the box-annotations region-creation overlay (a full-page pointer-events: auto div) now comes after the annotationLayer in DOM order and swallows clicks on link annotations. Give the annotationLayer z-index: 2 to lift links above the overlay while staying below the box-annotations region/highlight/drawing layers (z-index: 3) and popups (4), restoring the same stacking relationships as pdfjs-dist 4. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mickr
approved these changes
Jul 6, 2026
mrscobbler
added a commit
that referenced
this pull request
Jul 9, 2026
Revert the pdfjs-dist 6.0.227 bump (#1666) while v6 regressions are investigated. Restores engines.node >=20.0.0 (the bump only existed to satisfy pdfjs 6) and removes the annotationLayer z-index workaround from #1694, which compensated for v6's earlier page-layer insertion and is unnecessary on v4. Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Sophia <1317004+mrscobbler@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After the pdfjs-dist 4.3.136 → 6.0.227 upgrade (#1666), external link annotations in PDFs render but are not clickable.
Root cause
pdf.js renders each link as an invisible
<a>insidesection.linkAnnotationin the.annotationLayer, overlaying the visible text span. All page layers are absolutely-positioned siblings withz-index: auto, so DOM order decides hit-testing.pdf.js 6 inserts its layers earlier in the page render lifecycle than v4 did, which changes the sibling order:
canvasWrapper → ba-Layer--regionCreation → textLayer → annotationLayer— links on topcanvasWrapper → textLayer → annotationLayer → annotationEditorLayer → ba-Layer--regionCreation— the box-annotations region-creation overlay (full-page,pointer-events: auto, swallows clicks via PointerCapture) lands above the linksFix
Give
.annotationLayerz-index: 2inside.bp-doc: above the region-creation overlay (auto) and textLayer (1), below the box-annotations region/highlight/drawing layers (3) and popups (4). This restores the exact stacking relationships v4 had.Testing
Verified live against a devpod with both pdf.js versions A/B tested:
Note: pdf.js's native
annotationEditorLayer(rendered permanently disabled — box-annotations is used instead) now stacks below the link layer. Inert today; revisit if native pdf.js editors are ever enabled.🤖 Generated with Claude Code