Skip to content

ipywidget Accordion not working properly #677

@lopezvoliver

Description

@lopezvoliver

Here's a simple example of a label within an Accordion widget working in an ipyleaflet Map in a Jupyter notebook:

import ipyleaflet
import ipywidgets as widgets

label = widgets.Label("General Kenobi!")
accordion = widgets.Accordion(children=[label], titles=['Hello there!'])

m = ipyleaflet.Map()
toolbar = ipyleaflet.WidgetControl(widget=accordion, 
    position="topright",
)  
m.add(toolbar)
m

image

Closed accordion

image

Open

Here's the corresponding code for Solara:

import solara
import ipyleaflet
import ipywidgets as widgets

zoom = solara.reactive(6)
center = solara.reactive((0,0))

class Map(ipyleaflet.Map):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        label = widgets.Label("General Kenobi!")
        accordion = widgets.Accordion(children=[label], titles=['Hello there!'])
        toolbar = ipyleaflet.WidgetControl(widget=accordion, 
            position="topright",
        )  
        self.add(toolbar)


@solara.component
def Page():
    with solara.Column() as main:
        map = Map.element(  # type: ignore
            zoom=zoom.value,
            on_zoom = zoom.set,
            center=center.value,
            on_center=center.set,
            scroll_wheel_zoom=True,
            toolbar_ctrl=False,
            data_ctrl=False,
        )
        return main

Unfortunately, the accordion widget does not close:

solara_bug_accordion

Heres my information on Solara, ipyleaflet, and ipywidgets versions:

Solara version: 1.33.0
ipyleaflet version: 0.19.1
ipywidgets version: 8.1.3

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions