-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(workflow): stop subflows resizing themselves after every load #6639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8d6358c
fix(workflow): stop subflows resizing themselves after every load
waleedlatif1 3cce724
fix(workflow): gate container sizing on this session's reported layout
waleedlatif1 00ae253
Revert "fix(workflow): gate container sizing on this session's report…
waleedlatif1 a483d7a
fix(workflow): size containers from a state-aware child estimate
waleedlatif1 07a59eb
improvement(workflow): even out the gutter inside a container
waleedlatif1 1ed9525
improvement(workflow): give a container one source for its own gutter
waleedlatif1 70576a2
test(workflow-renderer): assert the subflow header's height, not its …
waleedlatif1 a12011e
fix(workflow-renderer): declare the act-environment global
waleedlatif1 ce31c53
fix(workflow): size a container from one snapshot of the store
waleedlatif1 a32bbe5
fix(workflow): size an unmeasured note as a note
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/node-position-utils.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { CONTAINER_DIMENSIONS } from '@sim/workflow-renderer' | ||
| import { describe, expect, it } from 'vitest' | ||
| import { | ||
| calculateContainerDimensions, | ||
| clampPositionToContainer, | ||
| } from '@/app/workspace/[workspaceId]/w/[workflowId]/utils/node-position-utils' | ||
|
|
||
| describe('calculateContainerDimensions', () => { | ||
| it('covers the child it holds plus one trailing padding', () => { | ||
| /* Child coordinates are relative to the container's own origin, so their | ||
| far edge is already the distance to cover. */ | ||
| const child = { x: 273, y: 207.5, width: 250, height: 112 } | ||
|
|
||
| expect(calculateContainerDimensions([child])).toEqual({ | ||
| width: child.x + child.width + CONTAINER_DIMENSIONS.RIGHT_PADDING, | ||
| height: child.y + child.height + CONTAINER_DIMENSIONS.BOTTOM_PADDING, | ||
| }) | ||
| }) | ||
|
|
||
| it('leaves the same gap under a child wherever the child sits', () => { | ||
| const gapUnder = (y: number) => | ||
| calculateContainerDimensions([{ x: 600, y, width: 250, height: 112 }]).height - (y + 112) | ||
|
|
||
| expect(gapUnder(400)).toBe(CONTAINER_DIMENSIONS.BOTTOM_PADDING) | ||
| expect(gapUnder(700)).toBe(CONTAINER_DIMENSIONS.BOTTOM_PADDING) | ||
| }) | ||
|
|
||
| it('holds a child pinned to the top-left clear of the chrome', () => { | ||
| /* The floor `clampPositionToContainer` applies is what encodes the header | ||
| and leading padding into the child's own coordinates — the sizing math | ||
| reads them from there rather than adding them again. */ | ||
| const pinned = clampPositionToContainer( | ||
| { x: -999, y: -999 }, | ||
| { width: 900, height: 900 }, | ||
| { width: 250, height: 112 } | ||
| ) | ||
|
|
||
| expect(pinned).toEqual({ | ||
| x: CONTAINER_DIMENSIONS.LEFT_PADDING, | ||
| y: CONTAINER_DIMENSIONS.HEADER_HEIGHT + CONTAINER_DIMENSIONS.TOP_PADDING, | ||
| }) | ||
| }) | ||
|
|
||
| it('falls back to the default box when it holds nothing', () => { | ||
| expect(calculateContainerDimensions([])).toEqual({ | ||
| width: CONTAINER_DIMENSIONS.DEFAULT_WIDTH, | ||
| height: CONTAINER_DIMENSIONS.DEFAULT_HEIGHT, | ||
| }) | ||
| }) | ||
|
|
||
| it('never sizes below the default box', () => { | ||
| expect(calculateContainerDimensions([{ x: 16, y: 66, width: 40, height: 20 }])).toEqual({ | ||
| width: CONTAINER_DIMENSIONS.DEFAULT_WIDTH, | ||
| height: CONTAINER_DIMENSIONS.DEFAULT_HEIGHT, | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,23 @@ | ||
| declare global { | ||
| /** | ||
| * React reads this to decide whether `act` is supported. It is not one of the | ||
| * ambient globals, so it has to be declared before it can be assigned. | ||
| */ | ||
| var IS_REACT_ACT_ENVIRONMENT: boolean | ||
| } | ||
|
|
||
| /** | ||
| * jest-dom only registers DOM matchers (`toHaveStyle`, `toHaveClass`, …), so it is | ||
| * dead weight outside a DOM environment. This package's mount tests opt into jsdom | ||
| * per file, so load it only when one is actually running — mirroring `apps/sim`. | ||
| */ | ||
| if (typeof document !== 'undefined') { | ||
| await import('@testing-library/jest-dom/vitest') | ||
| /* | ||
| * Without this React treats `act` as unsupported, and every render in the | ||
| * mount tests logs "The current testing environment is not configured to | ||
| * support act(...)" — around forty lines a run, which buries the output that | ||
| * matters when one of them fails. | ||
| */ | ||
| globalThis.IS_REACT_ACT_ENVIRONMENT = true | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.