Skip to content

fix: prevent image preview focus on touch pointerdown#253

Merged
ocavue merged 2 commits into
prosekit:masterfrom
maccman:codex/prevent-image-preview-focus
Jul 7, 2026
Merged

fix: prevent image preview focus on touch pointerdown#253
ocavue merged 2 commits into
prosekit:masterfrom
maccman:codex/prevent-image-preview-focus

Conversation

@maccman

@maccman maccman commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

Clickable image previews live inside the editor contenteditable. On touch surfaces, tapping a rendered image can let the browser focus the editor on pointerdown before the image click handler opens an external surface such as a lightbox. In mobile WebKit this can briefly raise the software keyboard.

Changes

  • Reuse the image preview lookup in defineImageClickHandler.
  • Add a pointerdown DOM event handler for clickable image previews that calls preventDefault() for non-mouse pointers.
  • Return false from the DOM handler so the event is not swallowed and the existing click handler still receives the click.
  • Keep mouse pointerdown unchanged for desktop behavior.

Verification

  • pnpm exec vitest run packages/core/src/extensions/image.test.ts passed: 24 tests.
  • pnpm typecheck passed.
  • pnpm lint passed.

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

@maccman is attempting to deploy a commit to the ocavue's projects Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/prosekit/meowdown/@meowdown/core@253
npm i https://pkg.pr.new/prosekit/meowdown/@meowdown/react@253

commit: 5be6dfc

@ocavue ocavue changed the title Prevent image preview focus on touch pointerdown fix: prevent image preview focus on touch pointerdown Jul 7, 2026
@ocavue ocavue merged commit 515d77b into prosekit:master Jul 7, 2026
10 checks passed
@ocavuebot ocavuebot mentioned this pull request Jul 7, 2026
maccman added a commit to maccman/meowdown that referenced this pull request Jul 8, 2026
…yboard

Preventing pointerdown (prosekit#253) suppresses the compatibility mouse events,
but iOS WebKit's tap-to-focus is a native gesture default action: tapping
an image preview still focuses the surrounding contenteditable and briefly
raises the software keyboard before the click handler opens its surface
(e.g. a lightbox). Only cancelling the tap's touchend stops it — which
also suppresses the synthetic click, so the image click handler now tracks
single-finger taps on previews itself (movement tolerance, resize-handle
and multi-touch exclusions) and fires onClick from touchend.

ImageClickPayload.event widens to MouseEvent | TouchEvent accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants