-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
pn.state.curdoc
is None
inside of a popup-function
#6332
Comments
Thanks, this is likely a HoloViews issue. |
Thanks, I wasn't sure where to post it, so I went with the panel repo because it touched |
FWIW, I was able to work around this problem by doing something like this: def popup(curdoc, index):
pn.state.curdoc = curdoc
# do stuff with index that depends on curdoc
sel_stream = Selection1D(source=dm, popup=partial(popup, pn.state.curdoc)) |
Yep that should work, any chance you'd consider submitting a fix to HoloViews, I think all that's needed is adding something like: from panel.io.state import set_curdoc
...
with set_curdoc(self.plot.document):
popup = popup(**stream.contents) here: https://github.com/holoviz/holoviews/blob/main/holoviews/plotting/bokeh/callbacks.py#L691 |
I'll give it a shot. |
Recently HoloViews added the capability to open a popup when selecting points in a plot. However the function invoked this way does not seem to propagate the
pn.state.curdoc
correctly, which results in a break in any logic that depends on this.ALL software version info
OS X Sonoma M1
Description of expected behavior and the observed behavior
When you add a subscriber to a stream, that subscriber has access to the current Bokeh document. However, when the popup function is invoked, this document is set to
None
.Complete, minimal, self-contained example code that reproduces the issue
If you run this with
panel serve
and select some points in the plot, thedebug
function will print a valid document, while thepopup
function will not.The text was updated successfully, but these errors were encountered: