Skip to content

fix(files): let a mouse wheel scroll CSV and XLSX previews horizontally - #6563

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/preview-horizontal-wheel
Aug 11, 2026
Merged

fix(files): let a mouse wheel scroll CSV and XLSX previews horizontally#6563
waleedlatif1 merged 3 commits into
stagingfrom
fix/preview-horizontal-wheel

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Hovering a CSV/XLSX preview table and scrolling does nothing sideways on a mouse whose wheel reports only deltaY — the horizontal overflow is reachable only by dragging the scrollbar
  • The zoomable previews (docx, pdf, pptx, image) already bind bindPreviewWheelZoom, whose horizontal branch maps a trackpad's deltaX, and Shift+deltaY on a plain mouse, onto scrollLeft. The tabular previews never bound anything
  • Extracted that branch into bindPreviewHorizontalWheel — sharing the delta logic with the zooming variant rather than duplicating it — and bound it in all three tabular preview containers (csv-table-preview, xlsx-preview, preview-panel's CsvPreview) via a useHorizontalWheelScroll ref callback
  • The new binder ignores ctrl/cmd+wheel, so browser page zoom still works over a table. These previews have no zoom of their own, unlike the zoomable ones

Latent until #6550: while the table was sized to the frame it never overflowed, so there was nothing to scroll. Independent of that PR though — the binder no-ops when scrollWidth <= clientWidth, so it is inert until the table is actually wider.

Type of Change

  • Bug fix

Testing

8 unit tests in preview-wheel-zoom.test.ts covering trackpad deltaX, Shift+wheel, plain vertical wheel (must stay vertical), ctrl/cmd passthrough, the no-overflow no-op, unbind, and capture from a child cell. Mutation-verified: 3 fail when the binder body is removed.

jsdom does no layout, so the tests assert the handler's contract rather than real scrolling. Verified actual behavior separately with trusted wheel events in headless Chromium, hovering a table cell:

plain wheelShift+wheel
unbound (today)scrolls down 200scrolls down 200 — no horizontal movement
bound (this PR)scrolls down 200scrolls right 200

Not yet exercised in the running app.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

The zoomable previews (docx, pdf, pptx, image) bind `bindPreviewWheelZoom`, whose
horizontal branch maps a trackpad's `deltaX` — and Shift+`deltaY` on a plain mouse —
onto the container's `scrollLeft`. The tabular previews never bound anything, which
did not matter while their table fitted the frame. Now that it is wider, a mouse
whose wheel reports only `deltaY` can reach the overflow solely by dragging the
scrollbar; hovering the table and scrolling does nothing sideways.
Extract that horizontal branch into `bindPreviewHorizontalWheel`, sharing the delta
logic with the zooming variant rather than duplicating it, and bind it in all three
tabular preview containers through a `useHorizontalWheelScroll` ref callback. The new
binder deliberately ignores ctrl/cmd+wheel so browser page zoom still works over a
table, since these previews have no zoom of their own.
@vercel

vercelBot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
docsSkippedSkippedAug 11, 2026 11:00pm

Request Review

@cursor

cursorBot commented Aug 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
UI-only wheel gesture handling for file previews. Low risk overall, with a small shared-path change in bindPreviewWheelZoom that also affects zoomable previews.

Overview
Enables horizontal mouse-wheel scrolling on wide CSV and XLSX table previews, so Shift+wheel (and trackpad deltaX) can reach overflow without dragging the scrollbar.

Extracts shared horizontal-wheel handling into bindPreviewHorizontalWheel (also reused by bindPreviewWheelZoom), including line/page delta conversion and preserving vertical movement on diagonal pans. Wires it into the three tabular preview containers via a new useHorizontalWheelScroll ref hook, while leaving ctrl/cmd+wheel to the browser for page zoom.

Reviewed by Cursor Bugbot for commit f987a15. Configure here.

Cancelling a wheel event is all-or-nothing, so applying only `scrollLeft`
after `preventDefault` dropped a diagonal trackpad pan's `deltaY` entirely.
Apply the vertical component too, except under Shift, which remaps `deltaY`
onto the horizontal axis and so has none left to spend.
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@greptile-apps

greptile-appsBot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds horizontal wheel handling to CSV and XLSX preview containers while preserving native vertical scrolling and browser zoom behavior.

  • Extracts shared horizontal-wheel handling from the zoomable-preview binder.
  • Normalizes line- and page-mode wheel deltas before applying them to scroll offsets.
  • Adds a callback-ref hook and binds it to all three tabular preview containers.
  • Adds focused tests for gesture handling, delta conversion, passthrough behavior, overflow checks, child-event capture, and cleanup.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

FilenameOverview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-wheel-zoom.tsExtracts shared horizontal-wheel handling and correctly converts wheel delta units before updating scroll offsets.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/use-horizontal-wheel-scroll.tsAdds a stable callback-ref hook that binds and cleans up the horizontal wheel listener with the preview node lifecycle.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-wheel-zoom.test.tsCovers horizontal, shifted, diagonal, modifier-key, overflow, delta-mode, child-capture, and unbinding behavior.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/csv-table-preview.tsxAttaches the horizontal-wheel callback ref to the CSV table’s scroll container using the required absolute import.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsxAttaches the horizontal-wheel callback ref to the inline CSV preview’s scroll container using the required absolute import.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/xlsx-preview.tsxAttaches the horizontal-wheel callback ref to the XLSX table’s scroll container using the required absolute import.

Reviews (3): Last reviewed commit: "fix(files): normalize wheel deltas to pi..." | Re-trigger Greptile

…lutely
A wheel delta is only in pixels when `deltaMode` says so — Firefox reports
mouse wheels in lines — while scroll offsets always are, so a three-line notch
moved the table three pixels. Convert line and page deltas before applying them.
@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@cursor review

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f987a15. Configure here.

@waleedlatif1
waleedlatif1 merged commit e31d2a9 into stagingAug 11, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/preview-horizontal-wheel branch August 11, 2026 23:11
Sign up for freeto 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

@waleedlatif1