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

Under panel 1.2.1, setting .visible to True for a widget that is initially created with visible=False doesn't toggle its visiblity #5354

Closed
giftculture opened this issue Jul 31, 2023 · 2 comments · Fixed by #5508
Milestone

Comments

@giftculture
Copy link

giftculture commented Jul 31, 2023

Thanks for contacting us! Please read and follow these instructions carefully, then delete this introductory text to keep your issue easy to read. Note that the issue tracker is NOT the place for usage questions and technical assistance; post those at Discourse instead. Issues without the required information below may be closed immediately.

ALL software version info

Panel v1.2.1

Description of expected behavior and the observed behavior

When creating a widget with visible=False, setting .visible to True doesn't reveal the widget. The below code works under panel v 1.2.0 as expected - it reveals the spinner, sleeps for 5 seconds, and then hides the spinner. Looking at the javascript console when the script is executed under panel v1.2.0, the css style ":host { display: none !important; }" is applied at the start, is removed when I click the submit button and .visible is set to true, and then added back once .visible is set to false

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

import panel as pn
import logging
import bokeh
import time
logger = logging.getLogger('panel.tifviewer')
pn.extension(sizing_mode='stretch_width') #stretch_width


pn.__version__

load_and_display_spinner = pn.indicators.LoadingSpinner(value=False, height=100, width=100, visible=False)                      
submit = pn.widgets.Button(name='submit', button_type='primary')
main_ui = pn.Column(
                pn.Row(
                    pn.pane.Markdown(f'## my panel version is {pn.__version__}'),
                ),
                pn.Row(
                    submit
                ),
                pn.Row(
                    load_and_display_spinner
                ),
              
          ) 

tabs = pn.Tabs(
    ('app', main_ui),
).servable()
    

def load_display(spinner, x):
    print(f"spinner is {spinner}")
    print(f'switch is {x}')
    if (x == 'on'):
        spinner.value = True
        spinner.visible = True
    if (x == 'off'):
        spinner.value = False
        spinner.visible = False

def do_some_task(event):
    load_display(load_and_display_spinner, 'on')
    time.sleep(5)
    load_display(load_and_display_spinner, 'off')
                

submit.on_click(do_some_task)

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

@philippjfr philippjfr added this to the v1.2.2 milestone Aug 1, 2023
@ahuang11
Copy link
Contributor

ahuang11 commented Aug 2, 2023

import panel as pn

pn.extension(sizing_mode="stretch_width")  # stretch_width

def toggle_visible(event):
    ls.visible = not ls.visible

ls = pn.widgets.LoadingSpinner(visible=False, value=True)
bt = pn.widgets.Button(name="Click me", button_type="primary")
bt.on_click(toggle_visible)

pn.Column(ls, bt).servable()

So if ls.visible = True initially, it works, but not if initialized with ls.visible = False

I think the reason is visibility: hidden doesn't get dropped
image

@emcd
Copy link

emcd commented Sep 2, 2023

I see a fix for this was slated for the v1.2.2 milestone and v1.2.2 was released yesterday. Is this going to be retargeted for v1.2.3? This is a fairly high visibility bug, if you'll pardon the pun.

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

Successfully merging a pull request may close this issue.

5 participants