Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing a widget's value as query parameter does not trigger value_throttled-bound callbacks #7482

Open
1 task
MP-MaximilianLattka opened this issue Nov 11, 2024 · 2 comments

Comments

@MP-MaximilianLattka
Copy link
Contributor

ALL software version info

Software Version Info
Python 3.12.7
Panel 1.5.3

Description of expected behavior and the observed behavior

While using widgets that support a value_throttled attribute (e.g. RangeSlider) and binding value_throttled to a callback works out fine, syncing the widget's value as a query parameter does not trigger the callback. It's worth mentioning that the widget's value is updated with the query parameters value.

In other words, while syncing a widget's value with a query parameter, the query parameter does not fire callbacks that are bound to value_throttled.

(Please don't confuse this issue with #7481 which features a similar code snippet)

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

import panel as pn
import pandas as pd

pn.extension("tabulator", notifications=False)

template = pn.template.BootstrapTemplate()

df_full = pd.DataFrame({"year": list(range(2000, 2021))})

table = pn.widgets.Tabulator(df_full)
slider = pn.widgets.RangeSlider(start=2000, end=2020, name='Years')

@pn.depends(slider.param.value_throttled, watch=True)
def filter_df(value):
    start, end = value
    table.value = df_full[(df_full["year"] >= start) & (df_full["year"] <= end)]

if pn.state.location:
    pn.state.location.sync(slider, {"value": "years"})

template.main.append(pn.Column(table))
template.sidebar.append(pn.Column(slider))
template.servable();

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

  • I may be interested in making a pull request to address this
@jbednar
Copy link
Member

jbednar commented Nov 11, 2024

Once you have the code above, you can reproduce this issue by serving that app with e.g. panel serve --port 5099 throttled_sync.py and visiting "http://localhost:5099/throttled_sync?years=%5B2000%2C+2007%5D". I find that it only respects the URL parameter when depending on value, even though (as I understand it) it should be fine to depend on value_throttled as well.

@nellenul
Copy link

I've run into the same issue as well, thanks for posting 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants