Skip to content

fix(reader): zoom linked images on single tap (#4757) - #4766

Merged
chrox merged 1 commit into
readest:mainfrom
chrox:fix/tap-zoom-linked-image-4757
Jun 24, 2026
Merged

fix(reader): zoom linked images on single tap (#4757)#4766
chrox merged 1 commit into
readest:mainfrom
chrox:fix/tap-zoom-linked-image-4757

Conversation

@chrox

@chrox chrox commented Jun 24, 2026

Copy link
Copy Markdown
Member

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

postSingleClick in src/app/reader/utils/iframeEventHandlers.ts returned 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 / table opens the viewer just like long-press:

const footnote = element?.closest(footnoteSelector);
const media = !isFixedLayout && !footnote ? detectMediaTarget(element) : null;
if (!media && element?.closest('sup, a, audio, video') && !element?.closest('a.duokan-footnote:not([href])')) {
  return;
}

Decision order is unchanged otherwise: footnote container class wins (forces media to null, 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 same media value (no second detectMediaTarget call).

Behavior

  • Reflowable + linked image -> opens the viewer (the fix)
  • Reflowable + footnote-link image -> footnote popup/navigation preserved
  • Plain text links, bare images, tables, fixed-layout tap-to-turn, and drag/long-hold guards -> unchanged

Tests

Updated src/__tests__/reader/utils/iframeEventHandlers.test.ts: the linked-image case now asserts iframe-open-media, plus a new footnote-link-image guard test confirming footnotes are excluded. Full pnpm test and pnpm lint pass.

🤖 Generated with Claude Code

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>
@chrox
chrox merged commit d963b91 into readest:main Jun 24, 2026
6 checks passed
@chrox
chrox deleted the fix/tap-zoom-linked-image-4757 branch June 24, 2026 15:57
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.

Not all images can be opened with a single tap

1 participant