posit-dev / py-shiny

Shiny for Python
https://shiny.posit.co/py/
MIT License
1.32k stars 81 forks source link

Action button as accordion panel icon ruins accordion #952

Open janion opened 10 months ago

janion commented 10 months ago

When adding an action button as the icon for an accordion panel, the accordion fails to render correctly. The first title is shown below the panel, and the rest of the panel do not appear at all.

image

Example app:

from shiny import App, Inputs, Outputs, Session, reactive, render, ui

def make_items():
    return [
        ui.accordion_panel(
            f'Section {letter}',
            f"Some narrative for section {letter}",
            icon=ui.input_action_button(id=letter, label='#'))
        for letter in "ABCDE"
    ]

app_ui = ui.page_fluid(
    ui.accordion(*make_items(), id="acc")
)

app = App(app_ui, None)

Thanks for producing this package, I'm really enjoying using it.

gadenbuie commented 10 months ago

@janion Thanks for opening the issue! In an accordion panel, the entire title area serves as a button that can be clicked to open or close the panel in the accordion. Can you explain a little more about your use case and why you're wanting to use a button as the accordion panel icon?

janion commented 10 months ago

I am using accordion panels to represent a sequence of items which can be individually configured. The button was going to be used as a delete button for each item.

I have found that an action link does work for my purpose, but I thought that this is still worth raising.