Skip to content

fix(embedded): viewport options breaking autolayout#3596

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/resource-view-al
Mar 15, 2026
Merged

fix(embedded): viewport options breaking autolayout#3596
icecrasher321 merged 1 commit intostagingfrom
fix/resource-view-al

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Separate out embedded viewport options.

Type of Change

  • Bug fix

Testing

Tested manually

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)

@cursor
Copy link

cursor bot commented Mar 15, 2026

PR Summary

Low Risk
Low risk UI-only change that adjusts ReactFlow viewport/zoom defaults for embedded rendering; main risk is minor regressions in initial zoom/pan behavior.

Overview
Embedded workflow rendering now uses its own viewport defaults.

Adds embeddedFitViewOptions and switches both onInit fitView and fitViewOptions to choose between embedded vs standard settings, preventing embedded viewport behavior from interfering with layout/fit-to-view.

Written by Cursor Bugbot for commit 75de6aa. Configure here.

@vercel
Copy link

vercel bot commented Mar 15, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 15, 2026 1:53am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 15, 2026

Greptile Summary

This PR fixes a bug where the embedded canvas was using the same fitViewOptions as the main workflow editor (padding: 0.6, maxZoom: 1.0), which caused ReactFlow's automatic fitView to produce a viewport that conflicted with the autolayout animation in embedded contexts. The fix adds a separate embeddedFitViewOptions constant (padding: 0.15, maxZoom: 0.85, minZoom: 0.35) and applies it conditionally in both the onInit callback and the fitViewOptions prop, leaving the non-embedded flow completely unaffected.

  • Added module-level embeddedFitViewOptions constant alongside the existing reactFlowFitViewOptions.
  • The onInit callback now passes the correct options object based on the embedded prop, so the initial programmatic fitView uses the right padding/zoom for each context.
  • The fitViewOptions prop on <ReactFlow> is updated consistently, so any future instance.fitView() call without explicit options also respects the embedded settings.
  • No impact on fitViewToBounds (used by autolayout and zoom-to-fit controls), since that utility calls setViewport() directly and ignores the fitViewOptions prop entirely.

Confidence Score: 5/5

  • This PR is safe to merge — it is a focused, low-risk bug fix with no side-effects on the non-embedded workflow editor.
  • The change is a two-line conditional swap using an already-present embedded boolean prop. The new constant follows the existing pattern (as const module-level), both the onInit call and the fitViewOptions prop are updated consistently, and fitViewToBounds (used by autolayout) is completely unaffected because it calls setViewport() directly.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Adds a dedicated embeddedFitViewOptions constant and uses it conditionally in both the onInit callback and the fitViewOptions prop so that embedded views no longer inherit the wide padding/zoom of the standard canvas; fix is clean and minimal with no side-effects on non-embedded flows.

Sequence Diagram

sequenceDiagram
    participant App as Workflow Page
    participant RF as ReactFlow
    participant onInit as onInit Callback
    participant FV as fitView()

    App->>RF: Render <ReactFlow fitViewOptions={embedded ? embeddedFitViewOptions : reactFlowFitViewOptions}>
    RF->>onInit: Fire onInit(instance)
    onInit->>FV: requestAnimationFrame → instance.fitView(embedded ? embeddedFitViewOptions : reactFlowFitViewOptions)
    Note over FV: Embedded: { padding:0.15, maxZoom:0.85, minZoom:0.35 }<br/>Normal: { padding:0.6, maxZoom:1.0 }
    FV-->>RF: Viewport applied
    RF-->>App: setIsCanvasReady(true) → canvas visible
Loading

Last reviewed commit: 75de6aa

@icecrasher321 icecrasher321 merged commit f572949 into staging Mar 15, 2026
12 checks passed
@icecrasher321 icecrasher321 deleted the fix/resource-view-al branch March 15, 2026 01:57
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