Skip to content

fix: enable vertical touch scrolling in mobile diff view#694

Merged
matt2e merged 1 commit intomainfrom
cant-scroll-vertically-on-phone
May 7, 2026
Merged

fix: enable vertical touch scrolling in mobile diff view#694
matt2e merged 1 commit intomainfrom
cant-scroll-vertically-on-phone

Conversation

@matt2e
Copy link
Copy Markdown
Contributor

@matt2e matt2e commented May 7, 2026

Summary

  • Fix inability to scroll vertically on phone in the diff view
  • Detect vertical vs horizontal touch intent and route vertical gestures to scroll the diff content instead of capturing them for horizontal drag
  • Expose a scrollApi from DiffViewer so DiffModal can programmatically scroll the diff panels during touch gestures
  • Defer pointer capture to horizontal drag only, allowing vertical scrolling to work naturally

Test plan

  • Open a diff on a mobile device or in mobile emulation
  • Verify vertical swipe scrolls the diff content up/down
  • Verify horizontal swipe still switches between before/after panels
  • Verify desktop behavior is unchanged

🤖 Generated with Claude Code

setPointerCapture was called immediately on pointer down, which stole
all touch events from the browser before the gesture direction was known.
Combined with overflow:hidden on all diff containers, this completely
blocked vertical scrolling on mobile.

Now the gesture direction is detected first (8px dead zone), and
setPointerCapture is only called when horizontal drag intent is
confirmed. For vertical intent, touch deltas are translated into
scrollController.scrollBy calls via a new bindable scrollApi prop
exposed by DiffViewer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners May 7, 2026 07:28
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 025af1eee0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +1069 to +1070
event.preventDefault();
diffViewerScrollApi?.scrollBy('after', -deltaY);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve mobile scrolling for markdown preview

When a Markdown diff is toggled to preview mode on a small viewport, the preview panes scroll via native overflow-y: auto on .code-area.markdown-mode, not via scrollController. This vertical branch now calls preventDefault() and only updates diffViewerScrollApi.scrollBy('after', ...), so a touch swipe that enters this mode can suppress the native preview scroll while changing an off-screen code-mode scroll position instead. Gate this path out for markdown preview or expose an API that scrolls the active markdown container.

Useful? React with 👍 / 👎.

@matt2e matt2e merged commit 5762835 into main May 7, 2026
6 checks passed
@matt2e matt2e deleted the cant-scroll-vertically-on-phone branch May 7, 2026 07:39
matt2e added a commit that referenced this pull request May 8, 2026
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: Claude Opus 4.6 (1M context) <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.

1 participant