title: Resetting shiny app after pressing submit button
body: <p>I have a functional shiny app whose logic is described below:</p>
  
  <p><strong>Logic of the app:</strong></p>
  
  <p>The user chooses one of the Tests by using the selectInput() "Label". This is the main operation and then he is able to modify its name, for example Test 1 to Test A. Then the user can add items in the Test by the numericInput() "Items in Test". These are the total items. As you will see the number of "Items in Test" is the same with 'Avail' column in hot3 table for the choosen Test. With "Select Items" he can choose specific items to be displayed in the hot5 table. Then the user can click on the hot5 table to select a specific item and the number of selected items (or rows) is displayed in the hot3 table under "Sel" column for this specific Test. The 'Items chosen' just displayes the number of Items selected in "Select Items". Note that every modification that happens to the table is not dependent on the other widgets. That means for example that it is not necessary to change a Label Name.    </p>
  
  <p><strong>Issue :</strong> </p>
  
  <p>Please have a look at the attached screenshot. I change the label of Test 2 into Test B, added 4 items and did not select them with the -click on the row - functionality. Then I press the submit button and I realize that after this, the setting of "Label" changes back to Test 1, but all the settings for Test B/Test 2 stay there in my app. This then looks as if I have the same settings for Test 1. I would like to be able after pressing the submit button OR choosing another test ('Label') the settings displayed are of the test you have selected under 'label'.So some kind of resetting if you press it, so that it corresponds to the actual settings of that test.</p>
  
  <p><a href="https://i.stack.imgur.com/3gIcV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3gIcV.png" alt="enter image description here"></a></p>
  
  <p><strong>App:</strong></p>
  
  <pre><code>library(shiny)
  library(DT)
  library(rhandsontable)
  #library(tidyverse)
  
  ui &lt;- navbarPage(
    "Application",
    tabPanel("Booklets",
             sidebarLayout(
               sidebarPanel(
                 uiOutput("tex2"),
                 rHandsontableOutput("hot3")
               ),
               mainPanel(
                 fluidRow(
                   wellPanel(
                     fluidRow(
                       column(4,
                              DT::dataTableOutput("hot5")
                       ),
                       column(4,
                              fluidRow(
                                uiOutput("book3"),
                                uiOutput("book6")
  
                              ),
                              fluidRow(
                                uiOutput("book1"),
                                uiOutput("book10"),
                                uiOutput("book11")
                              ),
                              fluidRow(actionButton("submit","submit"))
                       )
                     ))
                 )
               )
             )
    )
  )
  #server
  server &lt;- function(input, output, session) {
  
    rv&lt;-reactiveValues()
  
    output$tex2&lt;-renderUI({
      numericInput("text2", "#tests", value = 1, min=1)
    })
  
    output$book1&lt;-renderUI({
      numericInput("bk1",
                   "Items in test",
                   value = 1,
                   min = 1)
    })
  
    output$book3&lt;-renderUI({
  
      selectInput("bk3",
                  "Label",
                  choices=(paste("Test",1:input$text2)))
  
    })
  
  
    output$book6&lt;-renderUI({
      textInput("bk6", "Change to",
                value=NULL
      )
    })
  
  
    output$book10&lt;-renderUI({
      # changed from selectize
      selectizeInput(
        "bk10", "Select Items", choices =1:10000,multiple =T,selected = 1,
        options = list(maxItems = input$bk1))#changed from
    })
    output$book11&lt;-renderUI({
      textInput("bk11", "Items chosen",
                value = nrow(rt5())
      )
    })
  
    #rt4&lt;-reactive({
    observe({
      req(input$text2)
  
      rv$rt4 = data.frame(
        SNo = rep(TRUE, input$text2),
        Test=paste(1:input$text2),
        Label=paste("Test",1:input$text2),
        Avail=1L,
        Sel =as.integer(rep.int(0,input$text2)),
        stringsAsFactors = FALSE)
    })
  
    observeEvent(input$submit,{
  
      # rt4 &lt;- reactive({
      if (is.null( rv$rt4))
        return(NULL)
  
      if(!is.null(input$bk6) &amp;&amp; input$bk6!=""){
        rv$rt4[ rv$rt4$Label==input$bk3, "Avail"] &lt;- input$bk1
        rv$rt4[ rv$rt4$Label==(input$bk3), "Sel"] &lt;- length(input$hot5_rows_selected)
  
        rv$rt4[ rv$rt4$Label==input$bk3, "Label"] &lt;- input$bk6
      }
      else
      {
        rv$rt4[ rv$rt4$Label==input$bk3, "Avail"] &lt;- input$bk1
        rv$rt4[ rv$rt4$Label==(input$bk3), "Sel"] &lt;- length(input$hot5_rows_selected)
  
        #rv$rt4[ rv$rt4$Label==input$bk3, "Label"] &lt;- input$bk6
  
      }
    })
  
    observeEvent(input$submit,{
  
      updateSelectInput(session,"bk3","Label", choices=rv$rt4$Label)
    }
    )
  
  
    rt55&lt;-reactive({
      DF=data.frame(
        Id=  input$bk10,
        Label=paste("Item",input$bk10),
        Pf=0,
        stringsAsFactors = FALSE
      )
    })
  
    rt5&lt;-reactive({
      DF=data.frame(
        Id=  input$bk10,
        Label=paste("Item",input$bk10),
        Pf=0,
        stringsAsFactors = FALSE
      )
      cbind(id=rowSelected(), DF)
    })
  
    rowSelected &lt;- reactive({
      x &lt;- numeric(nrow(rt55()))
      x[input$hot5_rows_selected] &lt;- 1
      x
    })
  
    output$hot5 &lt;- renderDT(datatable(rt5()[,-1],
                                      selection = list(mode = "multiple",
                                                       selected = (1:nrow(rt5()[,-1]))[as.logical(rowSelected())],
                                                       target = "row"),rownames = F)
    )
  
    output$hot3 &lt;-renderRHandsontable({
      req(input$text2)
      rhandsontable(rv$rt4)
    })
  }
  shinyApp(ui,server)
  </code></pre>