title: Cannot update multiple select inputs in shiny at the same time in the first time
body: <p>I have a shiny app which has multiple <code>selectInput</code> and need to be dynamically updated. The R codes below show a minimum example to reproduce my question.</p>
  
  <p>There are two selectInput and one button. The default value is <code>A1</code> for <code>A</code> and <code>B1</code> for <code>B</code>. I will update <code>A</code> into <code>A2</code>, <code>B</code> into <code>B4</code> when I click the button. However, the <code>B</code> becomes <code>B3</code> in the first click (wrong result), but <code>B4</code> at the second click (correct result).</p>
  
  <p>It is really strange behavior. How could I fix this problem? Thanks for any suggestions. </p>
  
  <p>PS: I installed the latest version of shiny in github.</p>
  
  <p>Screenshots for three stages (initial, first click, second click).</p>
  
  <p><a href="https://i.stack.imgur.com/lMWoF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lMWoF.png" alt="enter image description here"></a></p>
  
  <p>Example codes to reproduce my problem. </p>
  
  <pre><code>library(shiny)
  df &lt;- data.frame(
      A = c('A1', 'A1', 'A2',  'A2'),
      B = c('B1', 'B2', 'B3', 'B4'),
      stringsAsFactors = FALSE
  )
  
  
  # Shiny UI
  ui &lt;- fluidPage(
      selectInput('sel1', 'A', choices = NULL, 
                    selected = NULL, 
                    selectize = FALSE)
      , selectInput('sel2', 'B', choices = NULL, 
                    selected = NULL, 
                    selectize = FALSE)
      , actionButton('clickme',  'Click me')
      )
  
  server &lt;- function(input, output, session) {
      observe({
          df_a &lt;- unique(df$A)
          updateSelectInput(session, 'sel1', choices = df_a, selected = NULL)
      })
      observe({
          req(input$sel1)
          df_b &lt;- df[df$A == input$sel1,]
          df_b &lt;- unique(df_b$B)
          updateSelectInput(session, 'sel2', choices = df_b, selected = NULL)
      })
      observe({
          req(input$clickme)
          updateSelectInput(session, 'sel1', selected = 'A2')
  
          updateSelectInput(session, 'sel2', selected = 'B4')
      })
  }
  
  shinyApp(ui, server)
  </code></pre>