ActionButton returns to zero, but when clicked again, the number of clicks does not reset. I'm using the Shiny.onInputChange function. Any ideas?
library(shiny)
ui <- fluidPage(
tags$script("Shiny.addCustomMessageHandler('resetInputValue', function(variableName){
Shiny.onInputChange(variableName, 0);});"),
titlePanel("ActionButton doesen't return to zero"),
sidebarLayout(
sidebarPanel(
splitLayout(
actionButton(inputId = "button",
label = "Button",
icon = icon("plus")),
actionButton(inputId = "reset",
label = "Reset",
icon = icon("power-off"))
)
),
mainPanel(
textOutput(outputId = "ButtonValue")
)
)
)
server <- function(input, output, session) {
output$ButtonValue <- renderText({
paste("Button current value:", input$button, sep = " ")
})
observeEvent(input$reset, {
session$sendCustomMessage(type = 'resetInputValue', message = "button")
})
}
shinyApp(ui = ui, server = server)