-
Notifications
You must be signed in to change notification settings - Fork 565
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
Mention how to freeze inputs #293
Comments
Probably somewhere in https://mastering-shiny.org/action-dynamic.html#updating-inputs |
Closed
Oh, that would be great to add. I didn't know about this. |
In ui <- fluidPage(
dateInput("date", "choose a date"),
selectInput("year", "Choose a year", choices = 2010:2030)
)
server <- function(input, output, session) {
observeEvent(input$date, {
year <- format(input$date, "%Y")
message("Changing year to ", year)
updateSelectInput(inputId = "year", selected = year)
})
observeEvent(input$year, {
date <- as.Date(ISOdate(input$year, 1, 1))
message("Changing date to ", date)
updateDateInput(inputId = "date", value = date)
})
} The key problem is that all updates processed by the browser in a single batch, after all observers have completed. This means that it since it starts in an inconsistent state it rapidly toggles back and forward. The easiest fix is to just set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rstudio/shiny#3055
The text was updated successfully, but these errors were encountered: