Skip to content

[Bug]: use for loop to assign multiple modal to multiple button fail #1926

Open
@xiaogangzhu

Description

@xiaogangzhu

Component

UI (ui.*)

Severity

P0 - Critical (crash/unusable)

Shiny Version

1.3.0

Python Version

3.12

Minimal Reproducible Example

from shiny import App, render, ui

app_ui = ui.page_fluid(
                        ui.input_action_button("show1", "Show doc1"),
                        ui.input_action_button("show2", "Show doc2"),
                        ui.input_action_button("show3", "Show doc3"),
)
def server(input, output, session):
    for i in range(1,4):
        @reactive.effect
        @reactive.event(input[f"show{i}"])
        def _():
            m = ui.modal(  
                f"This is a somewhat important message.{i}",  
                title="Somewhat important message",  
                easy_close=True,  
            )  
            ui.modal_show(m)  
app = App(app_ui, server)

Behavior

Current: click on each button will display

"This is a somewhat important message.3"

for all modal.

Expect: want to display

"This is a somewhat important message.1"
"This is a somewhat important message.2"
"This is a somewhat important message.3"

for each button

Error Messages (if any)

Environment

ubuntu 20

Metadata

Metadata

Assignees

No one assigned

    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