fix(files): zoom file viewer content, not the browser page#4741
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview
SVG file previews switch from a sandboxed Reviewed by Cursor Bugbot for commit d0f37e7. Configure here. |
Greptile SummaryThis PR fixes trackpad pinch-to-zoom on the file viewer by replacing React's synthetic
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to wheel-event handling and SVG rendering, with no impact on data, auth, or server-side logic. All three files make targeted, well-reasoned changes. The move to a non-passive native listener directly fixes the reported bug. The blob-URL lifecycle is handled correctly using useState+useEffect. The only cosmetic issue is the brief broken-image frame from the initial empty src string. preview-panel.tsx — the initial empty blobUrl state produces a brief broken-image placeholder; minor but worth addressing. Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User trackpad
participant Browser
participant Viewport as ZoomablePreview
participant WheelZoom as bindPreviewWheelZoom
participant ReactState as React state
User->>Browser: pinch gesture
Browser->>Viewport: WheelEvent with ctrlKey true
Note over Viewport,WheelZoom: Non-passive native listener in capture phase
Viewport->>WheelZoom: onWheel fires
WheelZoom->>WheelZoom: preventDefault stops browser zoom
WheelZoom->>ReactState: onZoom callback runs applyZoom
ReactState->>Viewport: re-render with new zoom transform
User->>Browser: two-finger pan
Browser->>Viewport: WheelEvent no modifier key
Viewport->>WheelZoom: onWheel fires
WheelZoom->>WheelZoom: onPan present so preventDefault
WheelZoom->>ReactState: onPan callback runs setOffset
ReactState->>Viewport: re-render with new offset transform
Reviews (2): Last reviewed commit: "fix(files): use effect lifecycle for SVG..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ 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 d0f37e7. Configure here.
Summary
metaKeyalongsidectrlKeyso Cmd+scroll on macOS zooms (matches Figma/tldraw/Excalidraw convention); this benefits all viewers usingbindPreviewWheelZoomincluding PDF, DOCX, and PPTX.<img src={blobUrl}>(browser-enforced secure static mode) instead of a sandboxed iframe — same security posture, and pinch events now reach the zoom container instead of being trapped in the iframe.Type of Change
Testing
Tested manually — trackpad pinch on images, SVG files, PDFs, DOCX, and PPTX now zooms the file content. Cmd+scroll on Mac also zooms. Two-finger pan and toolbar buttons work as before.
Checklist