Skip to content

fix: widget.link() to support HoloViews streams - #8450

Merged
philippjfr merged 2 commits into
holoviz:mainfrom
SuMayaBee:fix-holoviews-stream-link
Mar 2, 2026
Merged

fix: widget.link() to support HoloViews streams#8450
philippjfr merged 2 commits into
holoviz:mainfrom
SuMayaBee:fix-holoviews-stream-link

Conversation

@SuMayaBee

@SuMayaBee SuMayaBee commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Problem

Panel's widget.link() method is designed to create bidirectional connections between widgets and other parameterized objects. When we try to link a widget to a HoloViews stream (used for interactive plots), the connection appears to be made, but it doesn't actually work.

For example, when we write:

tabulator.link(selection_1d, selection="index", bidirectional=True)

We expect that clicking a row in the table will update the plot selection, and clicking a point in the plot will update the table selection. However, while the table selection changes correctly, the plot never updates because the stream's subscribers aren't notified.

The video demonstrates:

Before fix: Using a single tabulator.link() call doesn't work

PR3_Before.mp4

After fix: Using a single tabulator.link() call that works correctly

PR3_After.mp4

What's happening: The link() method uses setattr() to update the stream parameter. This sets the value correctly, but HoloViews streams need their .event() method to be called to notify all subscribers (like DynamicMap objects) that something changed. Without calling .event(), the stream value changes silently but nothing listening to the stream gets notified, so plots don't refresh.

The workaround required two separate pn.bind() calls:

def selection1d_to_tabulator(index):
    tabulator.selection = index

def tabulator_to_selection1d(selection):
    selection_1d.event(index=selection)

pn.bind(selection1d_to_tabulator, selection_1d.param.index, watch=True)
pn.bind(tabulator_to_selection1d, tabulator.param.selection, watch=True)

Solution

Modified Reactive.link() in panel/reactive.py to detect when the link target is a HoloViews Stream object. When detected, it calls .event() instead of setattr(), which properly triggers all stream subscribers and enables DynamicMap updates.

The fix is fully backward compatible — it only changes behavior for HoloViews stream targets. All other .link() calls work exactly as before.

Example

Before — required two pn.bind() calls:

pn.bind(selection1d_to_tabulator, selection_1d.param.index, watch=True)
pn.bind(tabulator_to_selection1d, tabulator.param.selection, watch=True)

After — one simple .link() call:

tabulator.link(selection_1d, selection="index", bidirectional=True)

Files Changed

  • panel/reactive.py — Updated Reactive.link() to call .event() on HoloViews stream targets

Related Issue

Closes #7801

AI Disclosure: I used Gemini 3 Flash to explore and understand the codebase while working on this fix.

@codecov

codecov Bot commented Feb 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.03%. Comparing base (49872f3) to head (2285dd7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
panel/tests/test_reactive.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8450      +/-   ##
==========================================
- Coverage   86.12%   86.03%   -0.09%     
==========================================
  Files         349      349              
  Lines       54971    54986      +15     
==========================================
- Hits        47343    47308      -35     
- Misses       7628     7678      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@SuMayaBee SuMayaBee changed the title Fix widget.link() to support HoloViews streams fix widget.link() to support HoloViews streams Mar 2, 2026
@SuMayaBee SuMayaBee changed the title fix widget.link() to support HoloViews streams fix: widget.link() to support HoloViews streams Mar 2, 2026
@philippjfr
philippjfr merged commit 93ac57a into holoviz:main Mar 2, 2026
21 checks passed
@github-actions

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support panel widget.link(stream, selection="index")

2 participants