fix: v2 - sync visual selected state of the node#2196
Open
maxy-shpfy wants to merge 1 commit into05-03-fix_v2_-_rectangle_selection_of_one_nodefrom
Open
Conversation
5 tasks
Collaborator
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
🎩 PreviewA preview build has been created at: |
8 tasks
This was referenced May 4, 2026
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.

Description
Fix-try
Fixes a visual bug where two nodes could simultaneously display the "selected" ring when switching between nodes. React Flow's
selectedprop can lag one frame behind the store'sselectedNodeId, causing both the previously selected and newly selected nodes to appear highlighted at the same time.A new utility function
isEditorVisualNodeSelectedis introduced to determine the correct selected state for a node by using the editor store as the source of truth:editor.selectedNodeIdis set, only that node is highlighted.editor.multiSelectionis non-empty, the store's list is used.selectedprop is used as a fallback (e.g., during rectangle drag before multi-selection sync).This logic is applied to
TaskNode,IONode, andEditorV2FlexNode.Related Issue and Pull requests
Type of Change
Checklist
Screenshots (if applicable)
Test Instructions
Selection ring vs context panel (v2 canvas)
Root cause
Canvas nodes were styling “selected” from React Flow’s
selectedprop, while the context panel and most editor behavior useEditorStore(selectedNodeId,multiSelection). Those two sources can diverge briefly:useFlowCanvasStatesyncs spec-derived nodes in auseLayoutEffectviapreserveSelection(current, specNodes). If a MobX-drivenspecNodesrefresh runs close to a click,currentmay not yet include React Flow’s latestselectchange, sopreserveSelectionsees no selected ids and reapplies nodes withoutselected: true. The store updates fromonSelectionChange/ click handlers (context panel looks correct), but the ring can disappear until selection changes again.!!selectedwitheditor.selectedNodeId === id) fixed the missing ring but introduced two rings on fast sequential clicks:editor.selectNode(newId)updates immediately, while the previous node can still receiveselected: truefrom React Flow for a frame—so both old (RF) and new (store) appeared selected.Options considered
useFlowCanvasStateonly (e.g. foldeditor.selectedNodeIdintopreserveSelection, or restore render-time sync)useSelectionBehavior; rings would lag untilmultiSelectionupdatesisEditorVisualNodeSelectedWhat we chose and why
We added
isEditorVisualNodeSelected(editor, nodeId, rfSelected)with explicit precedence:editor.selectedNodeIdis set → only that node is visually selected (stale RFselectedon other nodes is ignored — fixes double ring).editor.multiSelectionis non-empty → visuals follow the store list (post-debounce multi-select truth).selected(rectangle drag before debounced multi-sync, empty store, etc.).This aligns single-select visuals with the store (and the context panel), preserves immediate multi-select feedback from RF before debounce, and avoids a larger, riskier refactor of the global canvas sync pipeline for this change.