feat: Accept drops onto the canvas and keep nodes mounted when node types change - #77
Merged
Merged
Conversation
4 tasks
This was referenced Sep 29, 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
I added support for dropping data onto the canvas, so an app can build nodes from an external palette, and fixed nodes remounting whenever
node_typeschanges.drop_typeslists the MIME types the canvas accepts. When data of one of them is dropped, the canvas emits adropevent with the matcheddrop_type, the droppeddata(parsed from JSON when possible), the droppositionin flow coordinates, and atargetnaming the node, and handle when there is one, under the pointer. A handler registered withflow.on("drop", ...)decides what to add and whether to wire it to that handle. Drops of other types, and all drops whileeditableis False, are ignored, so files or text dragged onto the canvas do nothing. Draggablepanel_material_ui.MenuListitems (feat: Add draggable MenuList items panel-material-ui#746) work as a source, andexamples/drop_from_menu.pyshows a palette whose items are added where they are dropped and connected when dropped on an input.node_typesrebuilt the component for every node type, so React remounted every node on the canvas and detached its embedded view, which could leave Bokeh plots blank. Apps that register node types lazily, e.g. panel-flowdash when a component is first used, hit this on every new type. Each type's component is now cached and reused until its own spec or the popup settings change.Dragging "CSV file" onto the canvas adds a node where it is dropped; dragging "Database" onto the Sink's input also connects it.
I added a Python test for the
dropevent payload and UI tests for drops on the pane, a node and a handle, for ignored types and non-editable canvases, a demo test that drags realMenuListitems (skipped until panel-material-ui withdraggableis installed), and a test that a node with a Bokeh view keeps its DOM element and canvas when a new node type is added, which fails without the cache. I documented the event in "React to Events" and added release notes. The Python tests (172), the UI suite (70 passed, 1 skipped) and pre-commit pass.AI Disclosure
Tool & Model: Kilo Code + Claude Opus 5.5
Usage: Implemented the drop support, the remount fix and tests while wiring a component palette into panel-flowdash, and drafted this description; I reviewed the diff and ran the listed checks.
Checklist