title: Shiny interactive UI - not able to access new input variabel created using "insertUI"
body: <p>Thanks for your help in advance! After an R update my code did not work anymore.</p>
  <p>After creating, a new input variable with &quot;insertUI&quot; the new variable stays empty. Why? Maybe I struggel with the order of reactive calculations done in shiny.</p>
  <p>My aim is to let the user change the color of the barplot factor by factor. At the same time the user sould be able to exclude some factors from the dataset.
  I want to include the name of the factor in the color-selector, to make it easy for the user.</p>
  <p>Here is my reproducible example:</p>
  <pre><code>library(shiny)
  library(dplyr)
  library(tibble)
  library(shinyWidgets)
  library(ggplot2)
  
  
  ##load data
  x=as.data.frame(Titanic)
   str(x)
  choice_fac=colnames(x)[1:4]
  choice_col=c(&quot;steelblue&quot;, &quot;cornflowerblue&quot;,&quot;firebrick&quot;, &quot;palegoldenrod&quot;,&quot;forestgreen&quot;, &quot;darksalmon&quot;, &quot;olivedrab&quot;, &quot;plum&quot;)
  
  
  ui&lt;-fluidPage(
    
    fluidRow(
    column(&quot;Class:&quot;, checkboxGroupInput(&quot;Class_sel&quot;, &quot;&quot;, choices=levels(x[,1]), selected=levels(x[,1]), inline=FALSE), width=2, style='margin-bottom:10px;  padding: 10px;'),
    column(&quot;Sex:&quot; , checkboxGroupInput(&quot;Sex_sel&quot;, &quot;&quot;, choices=levels(x[,2]), selected=levels(x[,2]), inline=FALSE), width=2,style='margin-bottom:10px; padding: 10px;'),
    column(&quot;Age:&quot; ,checkboxGroupInput(&quot;Age_sel&quot;, &quot;&quot;, choices=levels(x[,3]), selected=levels(x[,3]), inline=FALSE), width=2,style='margin-bottom:10px; padding: 10px;'),
    column(&quot;Survived:&quot; ,checkboxGroupInput(&quot;Sur_sel&quot;, &quot;&quot;, choices=levels(x[,4]), selected=levels(x[,4]), inline=FALSE), width=2,style='margin-bottom:10px; padding: 10px;')
    ),
    selectInput(&quot;Fac_sel&quot;, &quot;Please select:&quot;, choices=choice_fac, selected=choice_fac[1], width = &quot;100%&quot;, multiple=FALSE),
    fluidRow(
      tags$div(id = 'placeholder_colors'),
              ),
     plotOutput(&quot;plot&quot;)
  
  )
  
  
  server&lt;-function(input, output){
    
  
    x_sel=reactive({
      x%&gt;%filter(Class %in% input$Class_sel,
                 Sex %in% input$Sex_sel,
                 Age %in% input$Age_sel,
                 Survived %in% input$Sur_sel)
      
    })
    
    
    col_match=reactive({
    
      col_n=x_sel()%&gt;%distinct(!!sym(input$Fac_sel))%&gt;%na.omit()
      col_n%&gt;%add_column(col=choice_col[1:nrow(col_n)])%&gt;%mutate(mycolor=paste(&quot;mycolor&quot;, row_number(), sep=&quot;&quot;))
    })
    
    observeEvent(c(input$Fac_sel, input$Class_sel, input$Sex_sel, input$Age_sel, input$Sur_sel) , {
      removeUI(selector = 'div:has(&gt;#mycolor1)')
      removeUI(selector = 'div:has(&gt;#mycolor2)')
      removeUI(selector = 'div:has(&gt;#mycolor3)')
      removeUI(selector = 'div:has(&gt;#mycolor4)')
      removeUI(selector = 'div:has(&gt;#mycolor5)')
      
      print(col_match())
      
        lapply(1:nrow(col_match()), function(i){
        insertUI(selector = &quot;#placeholder_colors&quot;, ui = column(colorSelectorInput(inputId =col_match()[i,3], label = paste(&quot;Farbe &quot;, i,&quot;: &quot;, col_match()[i,1], sep=&quot;&quot;), choices =choice_col, selected=col_match()[i,2]), width=3))
          }) 
  
    })
      
  
  input_col=reactive({
    x=c(input$mycolor1, input$mycolor2, input$mycolor3, input$mycolor4 , input$mycolor5, rep(&quot;blue&quot;,5) )
    y=x[1:nrow(col_match())]
    col_match()%&gt;%add_column(y)%&gt;%pull(y,!!sym(input$Fac_sel))
  })
  
  
  output$plot=renderPlot({
      x_sel()%&gt;%ggplot()+
      geom_col(aes(x=!!sym(input$Fac_sel), y=Freq, fill=!!sym(input$Fac_sel)))+
      scale_fill_manual(values=input_col())
                             })
  
  observe({print(input_col())})  
  observe({print(input$mycolor1)})  
  observe({print(input$mycolor2)})  
  observe({print(input$mycolor3)})  
  observe({print(input$mycolor4)})  
  observe({print(input$mycolor5)}) 
  
  }
  
  shinyApp(ui, server)
  </code></pre>