Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #18277
Closed
Open
Issue created Nov 17, 2015 by Administrator@rootContributor

Mismatch between documentation & implementation of collapse.js

Created by: mrharel

According to the documentation of Collpase.js:

The data-target attribute accepts a CSS selector to apply the collapse to.

However in the Collapse.js code:

// COLLAPSE PUBLIC CLASS DEFINITION
  // ================================

  var Collapse = function (element, options) {
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.$trigger      = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
                           '[data-toggle="collapse"][data-target="#' + element.id + '"]')

As you can see the this.$trigger will only be set to the triggering element only if it has in the data-target an ID, and not any CSS selector.

This might lead to some unexpected behavior, which the "collapsed" class is not being applied to the button.

See the following example

<button class="btn" data-target="#tab1" data-toggle="collapse" type="button">button1</button>
<button class="btn" data-target=".tab2" data-toggle="collapse" type="button">button2</button>

when clicking on button1, it will get the class "collpased" which will allow me to style it in different states for collapsed and expand, but the other button will not get this class.

I suggest other fix the documentation or change the code.

Assignee
Assign to
Time tracking