Skip to content

fix: suppress native mobile context menu on text selection#281

Open
grubmanItay wants to merge 1 commit intobacknotprop:mainfrom
grubmanItay:fix/suppress-mobile-context-menu
Open

fix: suppress native mobile context menu on text selection#281
grubmanItay wants to merge 1 commit intobacknotprop:mainfrom
grubmanItay:fix/suppress-mobile-context-menu

Conversation

@grubmanItay
Copy link
Contributor

Description

On mobile (iOS Safari, Android Chrome), long-pressing to select text triggers the native context menu (cut/copy/paste) which overlays the annotation toolbar/picker.


Fix

Two complementary techniques scoped to the annotation <article> container only:

  • CSS: -webkit-touch-callout: none — suppresses iOS Safari callout
  • JS: contextmenu event listener with preventDefault() in a dedicated useEffect, gated by (pointer: coarse) media query — suppresses Android Chrome and other mobile browsers

Desktop right-click remains unaffected.


File changed

File Change
packages/ui/components/Viewer.tsx Add useEffect for contextmenu suppression + -webkit-touch-callout: none inline style

Test Plan

Mobile — iOS Safari

  • Long-press to select text — native callout (cut/copy/paste) should NOT appear
  • Annotation toolbar/picker appears without obstruction
  • Text selection handles still work normally
  • All annotation modes work (Markup, Comment, Redline, Label)
  • Pinpoint mode tap works without context menu

Mobile — Android Chrome

  • Long-press to select text — native context menu should NOT appear
  • Annotation toolbar/picker appears without obstruction
  • Text selection handles still work normally
  • All annotation modes work (Markup, Comment, Redline, Label)

Mobile — Other browsers

  • Firefox Mobile — same behavior as above
  • Samsung Internet — same behavior as above

Desktop — No regressions

  • Right-click on content still works normally (context menu appears)
  • Text selection + annotation toolbar works as before
  • All modes (Markup, Comment, Redline, Label) unaffected

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.

1 participant