Problem in developing a RStudio addin based on the use of two "consecutive" ShinyGadgets

rstudio
addins

#1

Hi all,

I am quite new to shiny, so apologies if this is something obvious.

I'm currently trying to develop a RStudio addin in which I use a shinyGadget opened in a dialogViewer to collect some user input, get the input when "Done" is clicked and then fire up a second shinyGadget where the user can perform additional operations based on choices made in the first one.

The problem is that I can not find a way to get the second shinyGadget to work properly: you can see what I mean by running the code below: after clicking "Done" the second gadget is opened, but it is empty.

The weird thing (to me) is that if I put a browser() before the call to gadget2 so that execution is halted midway and then resume execution with c all works properly. Also, everything seems to work if I render the gadgets in RStudio paneViewer by switching from viewer = shiny::dialogViewer("") to viewer = shiny::paneViewer()

Any idea why is this happening? Is this some kind of bug in shiny::dialogViewer("") or I am missing something?

Thanks in advance!

Reprex

gadget = {
  shiny::runGadget(
    miniUI::miniPage(miniUI::miniContentPanel(
      shiny::fillRow(
        shiny::selectInput('format', 'Format',
                           c('kable', 'DT', 'rhandsontable')),
        height = '70px'
      ),
      miniUI::gadgetTitleBar(NULL)
    )),
    server = function(input, output) {
      shiny::observeEvent(input$done, {
        shiny::stopApp(returnValue = list("", input$format))
      })
      shiny::observeEvent(input$cancel, {
        shiny::stopApp()
      })
    },
    stopOnCancel = FALSE,
    viewer = shiny::dialogViewer("")
    )
}

#browser()

gadget2 = {
  shiny::runGadget(
    miniUI::miniPage(miniUI::miniContentPanel(
      shiny::fillRow(
        shiny::selectInput('format', 'Format',
                           c('kable', 'DT', 'rhandsontable')),
        height = '70px'
      ),
      miniUI::gadgetTitleBar(NULL)
    )),
    server = function(input, output) {
      shiny::observeEvent(input$done, {
        shiny::stopApp(returnValue = list("", input$format))
      })
      shiny::observeEvent(input$cancel, {
        shiny::stopApp()
      })
    },
    stopOnCancel = FALSE,
    viewer = shiny::dialogViewer("")
    )
}