Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateNumericRangeInput() - label not updating #441

Closed
effnstfn opened this issue Nov 16, 2021 · 2 comments
Closed

updateNumericRangeInput() - label not updating #441

effnstfn opened this issue Nov 16, 2021 · 2 comments

Comments

@effnstfn
Copy link

Hi,
I have a Conditional Panel with a numericRangeInput with a label. When I try to pass a new label through an updateNumericRangeInput, it is not updating. The value argument in the updateNumericRangeInput does update though.

Is this possible to fix this please? Thanks! :)

@jassler
Copy link
Contributor

jassler commented Nov 16, 2021

This seems like a bug to me as well.

Meanwhile as an alternative you could replace the label in your UI element with a textOutput and use renderText on it to change its value.

library(shiny)

ui <- fluidPage(
  shinyWidgets::numericRangeInput('a', textOutput('aLabel'), value = c(0, 5)),
  actionButton('change', label = 'Change label')
)

server <- function(input, output, session) {
  # reactive text value of our label
  rangeLabel <- reactiveVal('BEFORE label')

  # actual rendering of the text value
  output$aLabel <- renderText({ rangeLabel() })

  observeEvent(input$change, {
    # change value of reactive variable
    # that way renderText is called automatically
    rangeLabel('AFTER label')
  })
}

shinyApp(ui, server)

Or, if you're using shinyjs, html() can be pretty convenient.

library(shiny)

ui <- fluidPage(
  shinyjs::useShinyjs(),
  shinyWidgets::numericRangeInput('a', 'BEFORE label', value = c(0, 5)),
  actionButton(inputId = 'change', label = 'Change label')
)

server <- function(input, output, session) {
  shinyjs::onclick('change', shinyjs::html(selector = '#a label', html = 'AFTER label'))
}

shinyApp(ui, server)

@pvictor
Copy link
Member

pvictor commented Nov 16, 2021

Thanks for reporting this, it should be fixed if you re-install from GitHub.

@pvictor pvictor closed this as completed Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants