Skip to content

FileSelector remains partly hidden if shown hidden first #7510

Open
@pierrotsmnrd

Description

ALL software version info

Software Version Info
panel==1.5.4
MacOS 14.6.1

Description of expected behavior and the observed behavior

  • A FileSelector is first displayed with property visible=False
  • On a click on a button, its visible property is set to True
  • The FileSelector is not entirely displayed, only the horizontal line is shown

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

import panel as pn
pn.extension()

file_selector = pn.widgets.FileSelector('~/', name='Select Files', visible=False)
toggle_button = pn.widgets.Button(name='Show File Selector', button_type='primary')

def toggle_visibility(event):
    file_selector.visible = not file_selector.visible
    toggle_button.name = 'Hide File Selector' if file_selector.visible else 'Show File Selector'

toggle_button.on_click(toggle_visibility)
layout = pn.panel(pn.Column(toggle_button, file_selector))
layout.servable()

Diagnostic

FileSelector is a composite widget. After investigating the HTML structure, it appears that several components inside the _composite property remain with visible=False despite setting the FileSelector's visible property to True

Workaround

Updating the toggle_visibility function to this illustrates the diagnostic and gives the expected behavior

def toggle_visibility(event):
    file_selector.visible = not file_selector.visible
    file_selector._composite[0].visible =  file_selector.visible
    file_selector._composite[-1].visible = file_selector.visible
    toggle_button.name = 'Hide File Selector' if file_selector.visible else 'Show File Selector'

Stack traceback and/or browser JavaScript console output

None

Screenshots or screencasts of the bug in action

Enregistrement.de.l.ecran.2024-11-21.a.09.50.15.mov
  • I may be interested in making a pull request to address this (I just don't know exactly where the problem lies in the code, despite investigating. I need a hint :))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't correct or isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions