Repository navigation
fix(flow): keep the canvas viewport usable when coordinates go non-finite - #1098
Open
zheng1114567 wants to merge 1 commit into
Open
zheng1114567 wants to merge 1 commit into
zheng1114567 wants to merge 1 commit into
Conversation
A non-finite node position or viewport x/y/zoom poisons every transform and fit computed from the canvas. Browsers drop the invalid transform, so panning and zooming freeze while the zoom label keeps changing. Repair non-finite viewport state before it is written, skip nodes without usable coordinates when fitting the view, park broken nodes on a grid slot at render time, and keep the previous position when an AI edit draft omits one coordinate.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What happens
On the SOP canvas, panning and zooming can stop moving the nodes while the zoom label keeps changing. Clicking "fit" doesn't recover it either. After that, adding a node from the palette puts it at
left: NaNpx.Why
The stage transform became
translate(NaNpx, ...). Browsers drop an invalid transform, so#canvasStagestays frozen at the last valid value. The viewport state itself is NaN, andfit()keeps it that way becausebounds()doesn't filter nodes with unusable coordinates.freeSpot()reads the same state, so the next node gets NaN coordinates too.Fix
flowViewport: repair non-finite x/y/zoom before writing the transform, and skip nodes without finite coordinates inbounds().zoomAt/centerOn/revealignore non-finite inputs.renderCanvas(): a node with a broken position is placed on a grid slot instead of renderingleft: NaNpx, so the repaired position is what gets saved.mergeAIEdit/aiPlaceNode: check both x and y when deciding whether a draft position is usable. The edit path only checked x, so a draft that had x but no y could drop the position.How I checked
scale(0.55)while the label showed 60%, andfit()producedscale(NaN).webtest/tests/flow-viewport-recovery.test.mjs: poisoned viewport heals on zoom,freeSpotstays finite, broken node positions are repaired beforefit, and an x-only AI draft keeps the old position.node --test tests/*.test.mjsinwebtest: 217 passed.