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

Shiny Module UI elements #8

Open
davesteps opened this issue Aug 5, 2016 · 8 comments
Open

Shiny Module UI elements #8

davesteps opened this issue Aug 5, 2016 · 8 comments

Comments

@davesteps
Copy link

Hi,
Great work on the package, it is really useful.

I have an app which is using shiny modules to generate a load of selectizeInput elements. The normal UI elements are captured and restored by the URL no problem, but the inputs which are modules do not seem to be. I don't know if this is possible for the future?

http://shiny.rstudio.com/articles/modules.html

@aoles
Copy link
Owner

aoles commented Aug 5, 2016

Hi David,
thank you for your inquiry! I started developing the package before shiny modules were available, and the current implementation doesn't support them yet. I will look into possibilities of enabling it and keep you updated on the progress.

Cheers,
Andrzej

@davesteps
Copy link
Author

Thats great, thanks Andrzej.
To clarify, the module UI element are being included in the generated URL e.g.

Size-filter=&Vintage-filter=&FoF-filter=&

But they are not restored when loading the URL.

Best, David.

@davesteps
Copy link
Author

Sorry, I was mistaken. The server logic in my app was just resetting the contents of the UI elements! I have tried it on a basic example and it will restore the state of modularized inputs (at least selectizeInput).

I am however getting the same as #5 where multiple=T but only 1 item selected.

Many thanks!

@aoles
Copy link
Owner

aoles commented Aug 5, 2016

Thanks for the update! I've tried to reproduce the issue described in #5 but never succeed. The "Multiple select" widget in the example distributed with the package

runApp('~/Projects/shinyURL/inst/examples/widgets')

seems to work for me regardless the choices I make.

Could you maybe provide a MWE demonstrating the problem? This would be very helpful. Thanks!

@davesteps
Copy link
Author

This is what I was using:

library(shinyURL)
library(shiny)

filterModuleInput <- function(id){
  ns <- NS(id)
  selectizeInput(ns('filter'),label = id,choices = c('a','b','c'),multiple=T)
}

shinyApp(
  ui = fluidPage(
    titlePanel("Hello Shiny!"),
    sidebarLayout(
      sidebarPanel(
        filterModuleInput('F1'),
        filterModuleInput('F2'),
        filterModuleInput('F3'),
        sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30),
        shinyURL.ui()
      ),
      mainPanel(
        plotOutput("plot")
      )
    )
  ),
  server = function(input, output, session) {
    shinyURL.server(session)
    output$plot <- renderPlot({
      x <- faithful[, 2]
      bins <- seq(min(x), max(x), length.out = input$bins + 1)
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
  }
)


@aoles
Copy link
Owner

aoles commented Aug 5, 2016

Great, thanks David! I could reproduce the described behaviour and I can confirm that there is a problem with restoring single-valued inputs in selectizeInputs. I will look into this within the next few days.

Cheers,
Andrzej

aoles added a commit that referenced this issue Aug 8, 2016
…ult value when only one item is selected (fixes #5 and #8
@aoles
Copy link
Owner

aoles commented Aug 8, 2016

Hi David,
thanks again for reporting the issue and for providing a reproducible example illustrating it. With the help of your detailed report I was able to identify the problem. The bug was occurring only when the selectInput had no initial value set. It turned out that also uninitialized checkbox groups were affected by it. I've fixed this in the recent update.

Please let me know in case there are any remaining issues with using shinyURL in your app.

Cheers,
Andrzej

@davesteps
Copy link
Author

Nice one Andrzej, good to kill two birds with one stone! Thanks for the package 👍

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

2 participants