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

Bug with depends changing the Select widget options #853

Closed
xavArtley opened this issue Dec 6, 2019 · 1 comment · Fixed by #967
Closed

Bug with depends changing the Select widget options #853

xavArtley opened this issue Dec 6, 2019 · 1 comment · Fixed by #967
Labels
type: bug Something isn't correct or isn't working
Milestone

Comments

@xavArtley
Copy link
Collaborator

xavArtley commented Dec 6, 2019

Hello:
I encouter a bug with this sample of code

w1 = pn.widgets.StaticText(value='<h1>1</h1>')
w2 = pn.widgets.StaticText(value='<h1>2</h1>')
sel = pn.widgets.Select(value=w1, options={'l1': w1, 'l2': w2})
@pn.depends(sel.param.value)
def widget_displayed(selection):
    return sel.value
    
pn.Column(sel, widget_displayed)

The first selection change (l2) works as expected however if we switch back to the l1 selection this error is triggered:

Python failed with the following traceback: 
d:\python\python37-64\pyenv\py37\lib\site-packages\pyviz_comms-0.7.2-py3.7.egg\pyviz_comms\__init__.py _handle_msg L303
d:\pythonworkspace\modules\panel\panel\viewable.py _comm_change L692
d:\pythonworkspace\modules\panel\panel\viewable.py _change_event L716
d:\pythonworkspace\modules\panel\panel\viewable.py _process_events L706
d:\pythonworkspace\modules\panel\panel\widgets\select.py _process_property_change L109
d:\pythonworkspace\modules\panel\panel\util.py indexOf L67
	ValueError: StaticText(value='<h1>1</h1>') not in list

ezgif com-video-to-gif (4)

A workaround is the following code:

w1 = pn.widgets.StaticText(value='<h1>1</h1>')
w2 = pn.widgets.StaticText(value='<h1>2</h1>')
sel = pn.widgets.Select(value=w1, options={'l1': w1, 'l2': w2})
@pn.depends(sel.param.value)
def widget_displayed(selection):
    return pn.Column(sel.value)
    
pn.Column(sel, widget_displayed)
@xavArtley xavArtley added the TRIAGE Default label for untriaged issues label Dec 6, 2019
@philippjfr philippjfr added type: bug Something isn't correct or isn't working and removed TRIAGE Default label for untriaged issues labels Dec 6, 2019
@philippjfr philippjfr added this to the v0.7.1 milestone Dec 6, 2019
@philippjfr
Copy link
Member

This is related to the way updating on a reactive object is handled. Currently what happens is that it reuses the initially displayed object and simply updates it, so w1 is updated with the text from w2. This is obviously pretty problematic and we may well have to disable this optimization.

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