holoviz / pyviz_comms

Bidirectional communication for the HoloViz ecosystem
BSD 3-Clause "New" or "Revised" License
32 stars 15 forks source link

IPyWidgets inside Panel not displaying in JupyterLab #129

Open WarmCyan opened 4 months ago

WarmCyan commented 4 months ago

ALL software version info

Tested primarily in JupyterLab in Firefox, but happens in Chromium too, Ubuntu 20.04

Libraries: python: 3.12.3 bokeh: 3.4.1 ipywidgets: 8.1.3 ipywidgets_bokeh: 1.6.0 jupyter_bokeh: 4.0.5 jupyter_server: 2.14.1 jupyterlab: 4.2.2 jupyterlab_server: 2.27.2 jupyterlab_widgets: 3.0.11 panel: 1.4.4 pyviz_comms: 3.0.2

Description of expected behavior and the observed behavior

I'd expect that rendering a panel or column containing an ipywidget would display the ipywidget, but it currently does not, throwing a TypeError: this._manager._wManager is null error in the browser console:

Pasted image 20240614085416

I tried narrowing down the library/versions specifically where this breaks, it looks like the most recent ipywidgets update might be the cause? Specifically, jupyterlab-widgets 3.0.10 -> 3.0.11 and ipywidgets 8.1.2 -> 8.1.3

Screenshot with jupyterlab-widgets 3.0.10/ipywidgets 8.1.2 that works as expected:

Pasted image 20240614084324

and with jupyterlab-widgets 3.0.11/ipywidgets 8.1.3 that does not work:

Pasted image 20240614085125

(after executing that final cell, the browser console error shown above pops up)

I tried digging around a little bit to see what might be causing this. If it's helpful at all, I noticed that ipywidgets 8.1.3 added a fix for widgets not rendering in jupyterlab code consoles, and this included changes to the jupyterlab_widgets plugin.ts file that seem to be touching a lot of things related to widget managers: https://github.com/jupyter-widgets/ipywidgets/pull/3004/files#diff-210a803f02037bdcbb7ac415747e27c96e2c1d40d0bc0a70a1f09016886ac3c7

Complete, minimal, self-contained example code that reproduces the issue

import ipywidgets as ipw
import panel as pn
pn.extension("ipywidgets")
pn.Column(pn.widgets.Button(name="test"), ipw.Button(description="test"))
philippjfr commented 4 months ago

Thank you for reporting this.