Skip to content

ui.modal_remove() requires ui.modal_show() #1812

@gadenbuie

Description

@gadenbuie

Originally posted by @schloerke in #1810

Similarly, I can only hide the modal if it is programmatically shown.

What I'd like to have work: Shinylive App

from shiny.express import input, render, ui
from shiny import reactive


modal = ui.modal(ui.input_slider("n", "N", 0, 100, 20), footer = ui.input_action_button("close_btn", "Close modal"), easy_close=False)

modal

@reactive.effect
@reactive.event(input.close_btn)
def _():
    print("Start remove modal")
    ui.modal_remove()
    print("End   remove modal")

What does work: Shinylive App

from shiny.express import input, render, ui
from shiny import reactive


modal = ui.modal(ui.input_slider("n", "N", 0, 100, 20), footer = ui.input_action_button("close_btn", "Close modal"), easy_close=False)

@reactive.effect
def _():
    ui.modal_show(modal)

@reactive.effect
@reactive.event(input.close_btn)
def _():
    print("Start remove modal")
    ui.modal_remove()
    print("End   remove modal")

If the modal is already open, why am I required to programmatically open it to close it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions