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

DatetimePicker value not updated in other object's callbacks #3993

Open
thuydotm opened this issue Oct 13, 2022 · 3 comments
Open

DatetimePicker value not updated in other object's callbacks #3993

thuydotm opened this issue Oct 13, 2022 · 3 comments

Comments

@thuydotm
Copy link
Collaborator

Description of expected behavior and the observed behavior

Let's say we have a DatetimePicker, and a button "Click". We change the date time value, then directly click on the button. In the callback of the button, the selected value is not updated properly. It still shows the time before the latest selection.

It works OK if I first change the date time, click outside to close the pop up, and finally click on the button.

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

import panel as pn

dt = pn.widgets.DatetimePicker()

def watcher(event):
    print(event.new, dt.value)

btn = pn.widgets.Button(name='Click')

dt_watcher = dt.param.watch(watcher, 'value', onlychanged=True)
btn.param.watch(watcher, 'value', onlychanged=True)

pn.Row(dt, btn).servable()
@hoxbro
Copy link
Member

hoxbro commented Oct 13, 2022

I will fix this in #3990

@hoxbro
Copy link
Member

hoxbro commented Oct 13, 2022

After reading through your description a second time. I think the problem comes down to timing. The DatetimePicker updates on the close of the pop-up calendar, and when you click directly on the button, it doesn't have time to sync with the python side.

Nonetheless, I think #3990 will improve the experience.

@philippjfr
Copy link
Member

Yeah, this is an unfortunate consequence of the fact that events (like a button click) are handled immediately while model change events (like the value change of the DatetimePicker) are slightly throttled. Not sure I have a good suggestion for a fix.

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