You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the modal is already open, why am I required to programmatically open it to close it.
The short answer is that ui.modal_show() puts the modal UI inside a set of wrapper containers where ui.modal_remove() expects to find and remove it. If you just add the modal UI to the app UI, the modal isn't where ui.modal_remove() expects to find it.
You can get close by replicating the expected markup but even if you do that, you'll be missing out on event listeners that are set up by ui.modal_show().
I think Shiny Express makes the approach you tried (of just showing modal directly in the UI) more appealing, but in Shiny Core and in Shiny for R using an observe(showModal(init_modal)) is a common pattern and it seems less tempting to just add the modal UI directly into the app.
On the other hand, you make a great point and if we turned the modal into a custom element the pattern you described would be quite natural.
That said, another reason to use ui.modal_show() over render.ui() or similar is that ui.modal_show() and ui.modal_remove() can show and hide the modal within a reactive cycle, whereas using render.ui() would have to change state once per reactive cycle.
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
What does work: Shinylive App
If the modal is already open, why am I required to programmatically open it to close it.
The text was updated successfully, but these errors were encountered: