holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.73k stars 516 forks source link

Widget 'disabled' attribute breaks after toggling #7389

Open h-croser opened 1 week ago

h-croser commented 1 week ago

ALL software version info

Software Version Info ```plaintext Python 3.11.9 panel 1.5.2 (still working on 1.4.5) bokeh 3.6.0 jupyterlab 4.2.5 ```

Description of expected behavior and the observed behavior

Expected behaviour Setting the disabled attribute of a widget to False should result in the widget being editable.

Observed behaviour When the disabled attribute of widgets is set to True and then set to False, the attribute can be updated one more time and then fails to update further.

In the reproduction code below, clicking the Button named "toggle" once will see no change in disabled state. Clicking the "toggle" Button twice will see the state of the dummy widgets permanently set to disabled.

This behaviour occurs when the switching of states is done quickly (i.e. in a single function), but doesn't seem to occur when the switching is done in multiple cells of a notebook.

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

import panel as pn
pn.extension()

dummy_button = pn.widgets.Button(name="dummy", button_type='primary')
dummy_text = pn.widgets.TextAreaInput()
toggle_button = pn.widgets.Button(name="toggle")

def toggle(_):
    dummy_button.disabled = True
    dummy_text.disabled = True
    dummy_button.disabled = False
    dummy_text.disabled = False

toggle_button.on_click(toggle)

layout = pn.Column(dummy_button, dummy_text, toggle_button)
layout.servable()

Screenshots or screencasts of the bug in action

Before first click

before_click

After first click

after_first_click

After second click

after_second_click
h-croser commented 1 week ago

Adding that when the example code is run using panel serve bug.ipynb the bug doesn't occur. It does occur when included as part of a notebook and run using jupyter lab bug.ipynb