How can I have dropdown "chunks of inputs"?

I know the title is not very clear so here's an example:

library(shiny)
library(miniUI)
library(dqshiny)

ui <- miniPage(
  fillRow(flex = c(1, 1),
          fillCol(
            dq_accordion(
              id = "something",
              titles = list("First",
                            "Second"),
              
              contents = tagList(
                tagList(selectInput("foo",
                                    "foo",
                                    choices = names(mtcars))),
                
                tagList(
                  textInput("foo_2", "foo 2"),
                  textInput("foo_3", "foo 3"),
                  
                  checkboxInput("foo_4",
                                "foo_4",
                                value = TRUE)
                )
              )
            )
          )
          )
)

server <- function(input, output, session) {}

shinyApp(ui, server)

As you can see, when opening the first dq_accordion (I really don't know how to name this), there is a big white space that is due to the fact that the space below each dq_accordion is equal to the biggest space in one of the dq_accordion. Here, for example, there are more inputs (and hence a bigger space) in the second dq_accordion, which creates a white space in the first one. This is quite annoying because if I have a dq_accordion with a lot of inputs and one with one or two inputs, then the latter will display a big white space.

Do you know if there is a way to remove this white space? If not, do you know if another package provides this sort of dropdown panel?

Also asked on StackOverflow

If I was in your position, with a package that was my preferred option, but with undesired behavior, I would politely reach out to the package author to request a feature enhancement or for an indication of advice on how to modify the code for the desired behavior.

inspecting the page in chromes web inspector leads me to think there is something that calculates heights and sets them to explicit values, but it wasn't clear where the functionality for that was, I suspect it might even be in a javascript library.

Hi @nirgrahamuk, I have found an alternative with bsCollapse() and bsCollapsePanel() from the {shinyBS} package. Thanks for your advice anyway!

Here's my alternative:

library(shiny)
library(miniUI)
library(shinyBS)

ui <- miniPage(
  fillRow(flex = c(1, 1),
          fillCol(
            bsCollapse(
              id = "something",
              bsCollapsePanel(
                title = "First",
                tagList(selectInput("foo",
                                    "foo",
                                    choices = names(mtcars))
                        )
              ),
              bsCollapsePanel(
                title = "Second",
                tagList(
                  textInput("foo_2", "foo 2"),
                  textInput("foo_3", "foo 3"),
                  
                  checkboxInput("foo_4",
                                "foo_4",
                                value = TRUE)
                )
              )
            )
          )
  )
)

server <- function(input, output, session) {}

shinyApp(ui, server)
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.