Closed udurraniAtPresage closed 10 months ago
That's surprising and unintentional, sorry about that! Would you be willing to share more about how the modal is being created and shown? This minimal example seems to be working as expected:
library(shiny)
library(bslib)
ui <- page_sidebar(
sidebar = sidebar(
width = 280,
accordion(
accordion_panel(
"Click below",
actionButton("show", "Show modal")
)
)
)
)
server <- function(input, output) {
observeEvent(input$show, {
showModal(modalDialog("Hello"))
})
}
shinyApp(ui, server)
Your code works fine with both versions i.e., modal launches in the middle of the app. I found that the issue is with using the micromodal
package. Here's a reprex:
library(shiny)
library(micromodal)
library(bslib)
# Inputs ------------------------------------------------------------------
text_input <- function(id, label, width = "1200px", ...) {
textInput(
inputId = id,
label = HTML("<h4>", label, "<span style='color:red'>*</span>", "</h4>"),
width = width,
...
)
}
select_input_menu <- function(id, label, width = "1200px", ...) {
selectizeInput(id,
HTML("<h4>", label, "<span style='color:red'>*</span>", "</h4>"),
width = width,
options = list(
placeholder = "Please select an option",
onInitialize = I('function() { this.setValue(""); }')
),
...
)
}
slider_input_var <- function(id, label, sep = "", width = "1200px", ...) {
sliderInput(id,
label = HTML("<h4>", label, "<span style='color:red'>*</span>", "</h4>"),
sep = sep,
width = width,
...
)
}
radio_inv <- function(id, label, width = "1000px", ...) {
shinyWidgets::radioGroupButtons(
inputId = id,
label = HTML("<h4>", label, "<span style='color:red'>*</span>", "</h4>"),
choices = c(
"Strongly disagree",
"Slightly disagree",
"Agree",
"Slightly agree",
"Strongly agree"
),
selected = character(0),
# justified = TRUE,
checkIcon = list(
yes = icon("ok",
lib = "glyphicon"
)
),
width = width,
...
)
}
# Module UI ---------------------------------------------------------------
module_ui <- function(id, instructor_data) {
ns <- NS(id)
demographics <- div(
text_input(ns("namee"), label = "Full Name"),
select_input_menu(ns("gender"),
label = "Which gender do you best identify with?",
choices = list("M", "F", "Non-binary", "Prefer not to answer")
),
slider_input_var(ns("year"),
label = "In what year were you born?",
min = 1900,
max = 2023,
value = 1920,
step = 1
)
)
set1 <- div(
radio_inv(ns("inv1"), "I like sushi."),
radio_inv(ns("inv2"), "I like pizza.")
)
tagList(
actionButton(ns("start_intake"),
label = "Start",
`data-micromodal-trigger` = ns("modal-demos")
),
micromodal::micromodal(
id = ns("modal-demos"),
title = "Demographics",
content = tagList(
demographics
),
footer = tagList(
actionButton(ns("demos_submit"),
label = "Next",
`data-micromodal-trigger` = ns("modal-set1"),
`data-micromodal-close` = NA
)
)
),
micromodal::micromodal(
id = ns("modal-set1"),
title = "Set 1",
content = set1,
footer = tagList(
actionButton(ns("set1_submit"),
label = "Submit",
`data-micromodal-close` = NA
)
)
)
)
}
# Module Server ------------------------------------------------------------------
module_server <- function(id) {
moduleServer(
id,
function(input, output, session) {
}
)
}
# Main UI -----------------------------------------------------------------
ui <- page_navbar(
# Header
header = div(
use_micromodal(),
),
# Title
title = "Title",
# Sidebar ----------------------------------------------
sidebar = sidebar(
width = 280,
## Accordians
accordion(
accordion_panel(
"Intake Questionnaire",
icon = bsicons::bs_icon("files"),
module_ui("intake")
)
)
),
)
# SERVER ------------------------------------------------------------------
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
Hi @udurraniAtPresage, I think you'll need to check with the authors of the micromodal package. You can link back to this issue for reference. We'll be happy to help debug if we can, but at the moment it doesn't seem like something we can fix in bslib, so I'm going to close this issue.
This issue has been automatically locked. If you have found a related problem, please open a new issue (with a reproducible example or feature request) and link to this issue. :raising_hand: Need help? Connect with us on Discord or Posit Community.
Version 0.6.1 has a really cool look of shiny preset theme! But I have a functional issue as follows.
Problem Description
My sidebar has a button that launches a modal:
The module in the accordion has a button that launches a modal upon clicking. In bslib version 0.5.1, it launches in the middle of the app as desired:
But in version 0.6.1 it launches inside the sidebar:
I am not sure if this is a bug, but I always have modals launch in the middle of the app in the prior versions. Is there a workaround to make the modal launch in the middle of the app in version 0.6.1?
Session Info