fix(reader): zoom linked images on single tap (#4757) - #4766
Merged
Conversation
A single tap on an image wrapped in an <a> element followed the link instead of opening the image viewer, because postSingleClick returned early for any element inside an anchor before reaching media detection. Compute the media target up front and let it bypass the anchor guard, so a tapped image/table/svg-image opens the viewer just like long-press already does. Footnotes are excluded so footnote anchors keep their popup and navigation behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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
Fixes #4757. In reflowable books, a single tap on an image wrapped in an
<a>element followed the link instead of opening the image zoom viewer.Root cause
postSingleClickinsrc/app/reader/utils/iframeEventHandlers.tsreturned early for any element inside an anchor (element.closest('sup, a, audio, video')) before reaching the media-detection branch added in #4600. Long-press already opened the viewer for linked images (its listeners have no anchor skip), so single-tap was inconsistent.Fix
Compute the media target up front and let it bypass the anchor guard, so a tapped
img/svg-with-image/tableopens the viewer just like long-press:Decision order is unchanged otherwise: footnote container class wins (forces
mediatonull, so footnote markers rendered as images still show the popup), then image/table zooms, then link navigates, then page turns. The later dispatch reuses the samemediavalue (no seconddetectMediaTargetcall).Behavior
Tests
Updated
src/__tests__/reader/utils/iframeEventHandlers.test.ts: the linked-image case now assertsiframe-open-media, plus a new footnote-link-image guard test confirming footnotes are excluded. Fullpnpm testandpnpm lintpass.🤖 Generated with Claude Code