Skip to content

fix(files): attach wheel listener before paint and guard SVG src#4744

Merged
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/cursor-bot-preview-bugs
May 26, 2026
Merged

fix(files): attach wheel listener before paint and guard SVG src#4744
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/cursor-bot-preview-bugs

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Switch ZoomablePreview's wheel-listener binding from useEffect to useLayoutEffect so the native non-passive listener attaches before the browser paints. Closes the few-ms window after mount where a trackpad pinch could still zoom the browser page (the original bug fix(files): zoom file viewer content, not the browser page #4741 was meant to fix).
  • Guard the SVG <img> with {blobUrl && ...} so it doesn't render with an empty src on the first commit. Avoids the spec-edge-case current-document fetch and the broken-image flash before the effect populates the blob URL.

Context

Follow-up to #4741 — both findings flagged by Cursor Bugbot review on the merged commit.

Type of Change

  • Bug fix

Testing

Tested manually — pinch immediately after opening an image, PDF, DOCX, or PPTX preview no longer escapes to the browser. SVG previews no longer flash a broken-image icon on first render.

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)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 26, 2026 9:07pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 26, 2026

PR Summary

Low Risk
Patch-level devDependency bump with lockfile sync only; no runtime or product code changes in the diff.

Overview
Bumps the root turbo dev dependency from 2.9.12 to 2.9.14 and refreshes bun.lock so platform-specific @turbo/* optional packages match. The lockfile also records configVersion: 0 as part of the updated lock format.

This is a tooling-only change for monorepo scripts (build, dev, lint, etc.) that run through Turbo; no application source files are modified in this diff.

Reviewed by Cursor Bugbot for commit c5ddbcb. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 26, 2026

Greptile Summary

This PR is a targeted follow-up bug fix to #4741, addressing two edge cases in the file preview components identified during a post-merge review.

  • useLayoutEffect for wheel listener: Moves the non-passive wheel event listener binding from useEffect (after paint) to useLayoutEffect (before paint), closing the brief window after mount where a trackpad pinch could still trigger browser-level page zoom instead of in-component zoom.
  • SVG blob URL guard: Wraps the SVG <img> in {blobUrl && ...} so it is not rendered with an empty src string on the first commit — preventing both a spec-edge-case same-document fetch and the broken-image icon flash that appeared before the useEffect populated the blob URL.

Confidence Score: 5/5

Both changes are minimal, well-scoped, and directly address the reported bugs without touching any unrelated logic.

The useLayoutEffect substitution is consistent with how the rest of ZoomablePreview already operates (three other useLayoutEffect calls exist in the same file), and applyZoom has a stable useCallback identity so the listener is only bound once. The blobUrl && guard correctly leverages the falsy initial empty-string state to skip rendering. The turbo bump is a routine patch update. No regressions are expected.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/zoomable-preview.tsx Replaces useEffect with useLayoutEffect for wheel-listener binding so the non-passive listener is registered before the first paint, eliminating the race window where a pinch gesture could escape to browser zoom.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx Guards SVG <img> with {blobUrl && ...} to prevent rendering with an empty src before the blob URL is populated, avoiding a spec-mandated current-document fetch and broken-image flash.
package.json Bumps turbo from 2.9.12 to 2.9.14 — a routine patch-level dependency update with no functional impact on application code.
bun.lock Lockfile updated to reflect the turbo version bump and adds configVersion: 0; no other dependency changes.

Sequence Diagram

sequenceDiagram
    participant B as Browser
    participant R as React
    participant VP as Viewport DOM
    participant WL as Wheel Listener

    Note over R,VP: Before fix (useEffect)
    R->>VP: DOM mutations committed
    B->>B: Browser paints frame
    Note over B,WL: ⚠️ Pinch here escapes to page zoom
    R->>WL: useEffect fires → listener attached

    Note over R,VP: After fix (useLayoutEffect)
    R->>VP: DOM mutations committed
    R->>WL: useLayoutEffect fires → listener attached
    Note over WL: ✅ Listener in place before paint
    B->>B: Browser paints frame
    B->>WL: Pinch captured → preventDefault() → component zoom
Loading

Reviews (2): Last reviewed commit: "chore(deps): upgrade turbo to 2.9.14" | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 c5ddbcb. Configure here.

@waleedlatif1 waleedlatif1 merged commit 5d1aa22 into staging May 26, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/cursor-bot-preview-bugs branch May 26, 2026 21:14
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