title: Shiny modularized inputs inside pop-up modal aren't being written to reactiveValues when dismissed [flexdashboard/shinydashboard]
body: <p>As a minimally-viable example, I <a href="https://shiny.rstudio.com/articles/modules.html" rel="noreferrer">modularized</a> the basic example from here: <a href="https://rmarkdown.rstudio.com/flexdashboard/shiny.html#simple_example" rel="noreferrer">https://rmarkdown.rstudio.com/flexdashboard/shiny.html#simple_example</a></p>
  
  <h1>Code snippet (copy-paste, run as <code>.Rmd</code> in RStudio should do the trick):</h1>
  
  <pre><code>---
  title: "stackoverflow example"
  output: flexdashboard::flex_dashboard
  runtime: shiny
  ---
  
  ```{r global, include=FALSE}
  library(shiny)
  library(flexdashboard)  # install.packages("flexdashboard")
  # load data in 'global' chunk so it can be shared by all users of the dashboard
  library(datasets)
  data(faithful)
  
  # UI modules
  sidebarCharts &lt;- function(id) {
    ns &lt;- NS(id)
    tagList(
      p(),
      actionButton(ns("settings"), "Settings", icon = icon("cogs"), width = '100%', class = "btn btn-info"),p(),
      actionButton(ns("refreshMainChart") ,"Refresh", icon("refresh"), width = '100%', class = "btn btn-primary"),p()
      ,textOutput(ns("info"))  # FOR DEBUGGING
    )
  }
  
  mainChartUI &lt;- function(id) {
    ns &lt;- NS(id)
    plotOutput(ns("mainChart"), width = "100%")
  }
  
  # UI module for the 2 buttons in the modal:
  modalFooterUI &lt;- function(id) {
    ns &lt;- NS(id)
    tagList(
      modalButton("Cancel", icon("remove")),
      actionButton(ns("modalApply"), "Apply", icon = icon("check"))
    )
  }
  
  server &lt;- function(input, output, session) {
  
    # Init reactiveValues() to store values &amp; debug info; https://github.com/rstudio/shiny/issues/1588
    rv &lt;- reactiveValues(clicks = 0, applyClicks = 0,
                         bins = 20,
                         bandwidth = 1)
  
    # DEBUGGING
    output$info &lt;- renderText({
      paste("You clicked the 'Settings' button", rv$clicks, "times. You clicked the 'Apply' button", rv$applyClicks, "times. The bin size is currently set to", rv$bins, "and the bandwidth is currently set to", rv$bandwidth)
    })
  
    settngsModal &lt;- function(id) {
      ns &lt;- NS(id)
      modalDialog(
        withTags({  # UI elements for the modal go in here
          fluidRow(
            column(4, "Inputs",
                   selectInput(ns("n_breaks"), label = "Number of bins:", choices = c(10, 20, 35, 50), selected = rv$bins, width = '100%')),
            column(4, "Go",
                   sliderInput(ns("bw_adjust"), label = "Bandwidth adjustment:", min = 0.2, max = 2, value = rv$bandwidth, step = 0.2, width = '100%')),
            column(4, "Here")
          )
        }),
      title = "Settings",
      footer = modalFooterUI("inputs"), 
      size = "l",
      easyClose = FALSE,
      fade = TRUE)
    }
  
    # Sidebar 'Settings' modal
    observeEvent(input$settings, {
      showModal(settngsModal("inputs"))  # This opens the modal; settngsModal() defined below
      rv$clicks &lt;- rv$clicks + 1  # FOR DEBUGGING
    })
  
    observeEvent(input$modalApply, {
      rv$applyClicks &lt;- rv$applyClicks + 1  # FOR DEBUGGING
      rv$bins &lt;- input$n_breaks  # This is where I set the reactiveValues() to those inputted into the modal.
      rv$bandwith &lt;- input$bw_adjust
      removeModal()  # This should dismiss the modal (but it doesn't seem to work)
    })
  
    output$mainChart &lt;- renderPlot({
      input$refreshMainChart  # Take dependency on the 'Refresh' buton
  
      hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(rv$bins),  
           xlab = "Duration (minutes)", main = "Geyser Eruption Duration")
  
      dens &lt;- density(faithful$eruptions, adjust = rv$bandwidth)
      lines(dens, col = "blue")
    })
  
  }
  
  ```
  
  Column {.sidebar}
  -----------------------------------------------------------------------
  
  ```{r}
  callModule(server, "main")
  sidebarCharts("main")
  ```
  
  Column
  -----------------------------------------------------------------------
  
  ### Main chart goes here
  
  ```{r}
  mainChartUI("main")
  ```
  </code></pre>
  
  <h1>Screenshots:</h1>
  
  <p><a href="https://i.stack.imgur.com/riMJw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/riMJw.png" alt="Launch"></a>
  <a href="https://i.stack.imgur.com/KtYNg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KtYNg.png" alt="Modal"></a></p>
  
  <h1>This is the desired functionality:</h1>
  
  <ol>
  <li>On app launch, the chart should render with default parameters for bin-size and bandwidth stored in <code>rv</code> which is a <code>reactiveValues()</code> -- <strong>this appears to work.</strong></li>
  <li>When I click the modal, for the first time, it should appear with the default parameters for bin-size and bandwidth -- <strong>this also appears to work.</strong></li>
  <li>When I update either of the input parameters <strong>AND</strong> click 'Apply', it should dismiss the modal and subsequently set the respective parameters inside the <code>rv</code> <code>reactiveValues()</code> object to the one(s) selected -- <strong>THIS DOES NOT WORK</strong> (neither modal is dismissing, nor are <code>reactiveValues</code> being updated).</li>
  <li>After the <code>reactiveValues()</code> inside <code>rv</code> are updated with the new ones, the chart should NOT re-render until user hits the 'Refresh' <code>actionButton</code> -- this also does not work, but is contingent on (3) above.</li>
  </ol>
  
  <hr>
  
  <p>What am I doing wrong?? It feels like I'm overlooking something super simple.</p>
  
  <p>Thanks!!</p>