shinyStorePlus icon indicating copy to clipboard operation
shinyStorePlus copied to clipboard

Incompatible with shinyWidgets inputs

Open DIPAD-Fran-Bryden opened this issue 1 year ago • 3 comments

Hi, have found that your package works great with native Shiny inputs, but fails with inputs from the ShinyWidgets package.

Reprex:

library(shiny)
library(shinyWidgets)
library(shinyStorePlus)

# Define UI for application that draws a histogram
ui <- fluidPage(initStore(),

    # Application title
    titlePanel("Old Faithful Geyser Data"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            radioButtons("bins",
                        "Number of bins:",
                        choices = c(1, 3, 5)),
            
            shinyWidgets::radioGroupButtons("bins1",
                                            "Number of bins",
                                            choices = c(1, 3, 5))
        ),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = as.numeric(input$bins) + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
    
    #stores setup - save the values we gave it
    appid = "application31"
    setupStorage(appId = appid,inputs = TRUE)
    
}

# Run the application 
shinyApp(ui = ui, server = server)

In this example, the value passed to the regular radio buttons is saved but the one passed to the shinyWidgets buttons is lost.

DIPAD-Fran-Bryden avatar Apr 04 '23 12:04 DIPAD-Fran-Bryden