I'm hoping that someone here might be able to help me debug this issue that I'm having. The following code reproduces the problem:
remotes::install_github('ignacio82/IMPosterior')
library(shiny)
library(tidyverse)
library(htmltools)
library(shinyWidgets)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
p('The modal graph will not populate when run 2+ times. The static plot is fine (needs to be uncommented)'),
actionButton('run', 'Run')
),
# Show a plot of the generated distribution
mainPanel(
IMPosterior::IMPosteriorOutput("staticplot")
)
)
)
server <- function(input, output, session) {
im_object <- eventReactive(input$run,{
IMPosterior::IMPosterior(sample(-500:500,50,replace = T), MME = 10, threshold = .7)
})
# output$staticplot <- IMPosterior::renderIMPosterior({
# im_object()
# })
output$modalplot <- IMPosterior::renderIMPosterior({
im_object()
})
observeEvent(input$run,{
req(im_object())
showModal(modalDialog(
IMPosterior::IMPosteriorOutput('modalplot'),
title = 'Modal Plot',
easyClose = T,
size = 'm'
))
})
}
# Run the application
shinyApp(ui = ui, server = server)
To reproduce the problem:
Run
Dismiss
Run
The console shows the following error:
IMPosterior.js:454 Uncaught ReferenceError: dims is not defined
at Object.resize (IMPosterior.js:454)
at Object.resize (htmlwidgets.js:825)
at exports.OutputBinding.shinyBinding.resize (htmlwidgets.js:526)
at output_binding_adapter.js:12
at OutputBindingAdapter.onResize (utils.js:114)
at HTMLDivElement.<anonymous> (init_shiny.js:309)
at Function.each (jquery.min.js:2)
at n.fn.init.each (jquery.min.js:2)
at j (init_shiny.js:302)
at Debouncer.$invoke (input_rate.js:56)
Any suggestion for how to fix this?