Repository navigation
fix: Keep the selection when a view is mounted again - #101
Merged
Merged
Conversation
A newly mounted view started from nodes whose selected flags Python had not synced, so React Flow reported an empty selection and cleared it. Start the view's nodes and edges from the selection parameter, treat the flags it started from as the baseline for later node syncs, and skip React Flow's empty mount report.
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.
When a ReactFlow view is mounted again, for example when a dynamic tab hides and re-shows the canvas, the new view sent an empty selection and cleared the selection in Python. Python stores a browser selection on its nodes'
selectedflags without syncing them back, so the fresh view hydrated nodes that were all unselected, React Flow reported an empty selection, and that differed from theselectionparameter, so it was sent.I now start a view's nodes and edges from the
selectionparameter, treat the flags the view started from as the baseline for later node syncs (so a staleselectedflag does not read as Python selecting a node), and skip React Flow's empty first report when the view starts with a selection. Clicking the pane still deselects.I added a UI test that selects a node, then an edge, re-mounts the flow in a dynamic
pn.Tabseach time and checks the selection is kept and noselection_changedfires, then clicks the pane to deselect. It fails on main. The full UI suite (160) and unit tests pass, as does panel-flowdash'stests/ui/test_ui_sidecar_selection.pyagainst this branch. Once this is released, panel-flowdash can drop the 3 s selection window and theflow._process_msgwrapper added in panel-flowdash#246.Test timing fix
test_connection_validation_demostarted dragging right after the page served. It only passed because main's mount sent an extra selection round trip; it now waits for the initial fitView with_wait_for_viewport, like the other drag tests, since a fitView landing mid-drag turns the drag into a pan.