Help understanding changes to updating custom inputs in >=1.8.0

Hello everyone, I'm trying to update a Shiny app to the latest version and I'm seeing different behavior between 1.7.5.1 and 1.8.0 that I'm struggling to understand. From the changelog, I can see that some changes to how input bindings work were made, but I'm not familiar enough with Shiny under the hood to quite figure out how that's connected to this issue.

In this reprex, there are two numeric inputs, one custom via tags$input() and one standard via numericInput(). There are also two button inputs and each button will update the corresponding numeric input. In 1.7.5.1, updateNumericInput() would work with the custom input, but in 1.8.0 and above, that's no longer the case:

devtools::install_version("shiny", version = "1.7.5.1", repos = "http://cran.us.r-project.org")
library(shiny)

ui <- fluidPage(
    titlePanel("Shiny >=1.8 Custom Input Updating"),
    sidebarLayout(
        sidebarPanel(),

        mainPanel(
          
          tags$input(
            id = "customNum",
            type = "number",
            value = 0,
            class = "form-control shiny-bound-input required"
          ),
          shiny::actionButton(
            inputId = "setCustom",
            label = "Update Custom"
          ),
          
          
          shiny::numericInput(
            inputId = "standardNum",
            label = "Standard",
            value = 0
          ),
          shiny::actionButton(
            inputId = "setStandard",
            label = "Update Standard"
          )
        )
    )
)

server <- function(input, output) {

  observeEvent(input$setCustom, {
    shiny::updateNumericInput(
      inputId = "customNum",
      value = 10
    )  
  })
  
  observeEvent(input$setStandard, {
    shiny::updateNumericInput(
      inputId = "standardNum",
      value = 10
    )  
  })
  
}

shinyApp(ui = ui, server = server)

I've worked around this in the meantime by sacrificing a little bit of UI customization and just using numericInput(), but I'm hoping someone might understand what's driving this in >=1.8.0 and be able to offer advice on fixing.
Thank you Posit Community!

I cannot answer about the change in 1.8.0, but maybe you could customize the UI style of the numericInput inside a div as in

div(style = "margin-right:0; padding-right:0",
          numericInput(
            inputId = "standardNum",
            label = "Standard",
            value = 0
          )
 )

replace with shiny-input-number

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.