0

I have been working with shinyBS to create a set of collapsible panels. In the one shown below, only one panel should be open at a time (since the parameter multiple defaults to FALSE), but all three can be opened at the same time.

ui.R

library(shiny)
library(shinyBS)
shinyUI(fluidPage(
      bsCollapse(
        id = "stuff.all", 
        bsCollapsePanel(title = "Load Data", "Load the files"),
        bsCollapsePanel(title = "Set Parameters", "Set the parameters"),
        bsCollapsePanel(title = "Teacher Settings", "Choose the teachers")
      )
))

server.R

library(shiny)
library(shinyBS)
shinyServer(function(input, output) {})

What is causing this bsCollapse to act as though multiple = TRUE, and how can I prevent it in the future? Reference: https://ebailey78.github.io/shinyBS/docs/Collapses.html

I actually figured this out while writing the question, so I plan to answer my own question.

Paul de Barros
  • 1,170
  • 8
  • 22

1 Answers1

4

The id for bsCollapse in my example was "stuff.all". The fact that a period was part of the id seems to be what created the problem. When I changed the id to "stuff", the problem went away. When the id is "stuff.al" or "stuff.a", the problem persists. When the id is "stuff." or ".stuff", none of the panels expand when clicked. Given the way that bsCollapse works, the problem arises either from having a period in the id of an HTML <div> tag like so:

<div class="panel-group sbs-panel-group" data-sbs-multi="FALSE" id="stuff.a" role="tablist">

or from having a period in the data-toggle of an HTML <a> tag, like so:

<a data-toggle="collapse" href="#cpanel0758223" data-parent="#stuff.a">Load Data</a>
Paul de Barros
  • 1,170
  • 8
  • 22
  • This is related to the use of the dot operator in CSS. Read more here: http://stackoverflow.com/questions/12811149/what-does-the-dot-mean-in-css – Paul de Barros Jan 05 '16 at 13:17