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

Cannot reopen popup when using reference examples #6342

Closed
MarcSkovMadsen opened this issue Jul 26, 2024 · 2 comments · Fixed by #6347
Closed

Cannot reopen popup when using reference examples #6342

MarcSkovMadsen opened this issue Jul 26, 2024 · 2 comments · Fixed by #6347
Assignees
Labels
type: bug Something isn't correct or isn't working

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Jul 26, 2024

holoviews==1.19.1

I would like to try out the new pop up form with HoloViews and Panel.

Unfortunately the user experience of the Panel reference example in https://holoviews.org/user_guide/Custom_Interactivity.html is pretty bad if you choose to close the form by clicking the close button.

image

When you select some other datapoints the description will be hidden.

image

import panel as pn
import numpy as np
import holoviews as hv

pn.extension()

def popup_form(index):
    def hide_popup(_):
        layout.visible = False

    if not index:
        return
    df = points.iloc[index].dframe().describe()
    button = pn.widgets.Button(name="Close", sizing_mode="stretch_width")
    layout = pn.Column(button, df)
    button.on_click(hide_popup)
    return layout


points = hv.Points(np.random.randn(1000, 2))
hv.streams.Selection1D(source=points, popup=popup_form)

points.opts(
    tools=["box_select", "lasso_select", "tap"],
    active_tools=["lasso_select"],
    size=6,
    color="black",
    fill_color=None,
    width=500,
    height=500
)

pn.panel(points).servable()
@MarcSkovMadsen MarcSkovMadsen added the type: bug Something isn't correct or isn't working label Jul 26, 2024
@MarcSkovMadsen
Copy link
Collaborator Author

MarcSkovMadsen commented Jul 26, 2024

I experience the same behavior with the example from the original PR

import panel as pn
import numpy as np
import holoviews as hv
hv.extension("bokeh")


points = hv.Points(np.random.randn(1000, 2))

def form(name):
    text_input = pn.widgets.TextInput(name='Description')
    button = pn.widgets.Button(name='Save', on_click=lambda _: layout.param.update(visible=False))
    layout = pn.Column(f'# {name}', text_input, button)
    return layout

hv.streams.BoundsXY(source=points, popup=form('Bounds'))
hv.streams.Lasso(source=points, popup=form('Lasso'))
hv.streams.Tap(source=points, popup=form('Tap'))

pn.panel(points.opts(tools=['box_select', 'lasso_select', 'tap'], width=600, height=600, size=6, color='black', fill_color=None)).servable()

Once you've clicked save once you cannot open/ see the pop up again.

@MarcSkovMadsen MarcSkovMadsen changed the title Very bad user experience from reference pop up example Cannot reopen popup when using reference examples Jul 27, 2024
@MarcSkovMadsen
Copy link
Collaborator Author

I believe the cause is where marked below.

If there is an invisible _existing_popup the new pop up will new become an element of the panel. I don't understand why.

image

@ahuang11 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants