Fix: Distinguish empty handle arrays from undefined to allow hiding ports#37
Merged
philippjfr merged 2 commits intomainfrom Feb 11, 2026
Merged
Fix: Distinguish empty handle arrays from undefined to allow hiding ports#37philippjfr merged 2 commits intomainfrom
philippjfr merged 2 commits intomainfrom
Conversation
Co-authored-by: MarcSkovMadsen <42288570+MarcSkovMadsen@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with hiding input and output handles
Fix: Distinguish empty handle arrays from undefined to allow hiding ports
Feb 9, 2026
MarcSkovMadsen
approved these changes
Feb 9, 2026
Contributor
MarcSkovMadsen
left a comment
There was a problem hiding this comment.
Works for me and local Claude.
Test Example
"""Test app for verifying the hide-port-handles fix.
This app demonstrates three handle behaviors:
1. Default handles (null/undefined inputs/outputs) -> shows default handle dots
2. Empty handles (inputs=[] / outputs=[]) -> hides handles completely
3. Named handles (inputs=["a","b"] / outputs=["x"]) -> shows named port handles
"""
import panel as pn
from panel_reactflow import EdgeSpec, NodeSpec, NodeType, ReactFlow
pn.extension("jsoneditor")
# Define three node types to test all handle cases
node_types = {
# Case 1: No inputs/outputs specified (None) -> default handles
"default_handles": NodeType(
type="default_handles",
label="Default Handles",
inputs=None,
outputs=None,
),
# Case 2: Empty lists -> NO handles at all
"no_handles": NodeType(
type="no_handles",
label="No Handles",
inputs=[],
outputs=[],
),
# Case 3: Named ports -> shows named handles
"named_handles": NodeType(
type="named_handles",
label="Named Handles",
inputs=["in_a", "in_b"],
outputs=["out_x"],
),
}
nodes = [
NodeSpec(
id="n1",
type="default_handles",
position={"x": 50, "y": 50},
label="Default (should have dots)",
).to_dict(),
NodeSpec(
id="n2",
type="no_handles",
position={"x": 50, "y": 200},
label="Empty [] (NO dots)",
).to_dict(),
NodeSpec(
id="n3",
type="named_handles",
position={"x": 50, "y": 350},
label="Named ports (2 in, 1 out)",
).to_dict(),
# A plain "panel" node (built-in) for comparison - should have default handles
NodeSpec(
id="n4",
type="panel",
position={"x": 350, "y": 125},
label="Built-in panel type",
).to_dict(),
]
edges = [
EdgeSpec(id="e1", source="n1", target="n4").to_dict(),
EdgeSpec(id="e3", source="n3", target="n4", label="named->panel").to_dict(),
]
flow = ReactFlow(
nodes=nodes,
edges=edges,
node_types=node_types,
min_height=600,
sizing_mode="stretch_both",
)
description = pn.pane.Markdown(
"""## Handle Visibility Test
- **Node 1 (Default Handles)**: `inputs=None, outputs=None` — should show default handle dots on left and right
- **Node 2 (No Handles)**: `inputs=[], outputs=[]` — should have **NO** handle dots at all
- **Node 3 (Named Handles)**: `inputs=["in_a","in_b"], outputs=["out_x"]` — should show 2 left handles + 1 right handle
- **Node 4 (Built-in panel)**: Default built-in type — should show default handle dots
""",
sizing_mode="stretch_width",
)
layout = pn.Column(description, flow, sizing_mode="stretch_both", min_height=700)
layout.servable()
philippjfr
approved these changes
Feb 11, 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.
Empty handle arrays (
inputs=[]oroutputs=[]) were rendering default handles instead of hiding them. TherenderHandlesfunction used!handles?.lengthwhich is falsy for bothnull/undefinedand[], preventing users from creating source/sink nodes without unwanted ports.Changes
src/panel_reactflow/models/reactflow.jsxArray.isArray(handles) && handles.length === 0→ returnnullnull/undefined→ render default handle (unchanged)Example
Before/After
Before: Both nodes show handles on both sides despite empty arrays

After: Source has no left handle, sink has no right handle

Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.