I want to write a module with a dynamic number n of , say, interface elements. I noticed that the input slot does not match the current number of elements, but the largest number selected during the session:
library(shiny) library(plyr) testUI <- function(id) { ns <- NS(id) uiOutput(ns("container")) } test <- function(input, output, session, numElems) { output$container <- renderUI(do.call(tagList, llply(1:numElems(), function(i) selectInput(session$ns(paste0("elem", i)), label = i, choices = LETTERS[sample(26, 3)])))) getNames <- reactive(reactiveValuesToList(input)) list(getNames = getNames) } ui <- fluidPage(numericInput("n", "Number of Elems", value = 3), testUI("column1"), verbatimTextOutput("debug")) server <- function(input, output, session) { getN <- reactive(input$n) handler <- callModule(test, "column1", getN) output$debug <- renderPrint(handler$getNames()) } shinyApp(ui, server)
If you change the number of elements in the field of numerical inputs from 3 to 2 , we will see that there are 3 more elements in input . Is this behavior intentional? If so, how can I update input to state that it contains only available slots?
Refresh
Here are two relevant screenshots:


source share