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

Inconsistent behavior after using collapse('show') on Accordion #21168

Closed
davidtgq opened this issue Nov 20, 2016 · 5 comments
Closed

Inconsistent behavior after using collapse('show') on Accordion #21168

davidtgq opened this issue Nov 20, 2016 · 5 comments
Labels

Comments

@davidtgq
Copy link

davidtgq commented Nov 20, 2016

http://codepen.io/anon/pen/zoNyvO?editors=1010#0

To reproduce the problem:

  1. Open Item #2. It automatically collapses Item #1.
  2. Open Item #1 again. Item #2 does not automatically collapse.

The above steps can be also reproduced substituting Item 3 in lieu of Item 2 to demonstrate the same problem where Item 3 stays open.

The problem does not exhibit when:

  • using .in instead of collapse('show')

  • collapse('show') is removed such that the page loads with all items collapsed

@bardiharborow
Copy link
Member

bardiharborow commented Nov 21, 2016

Confirmed in Chrome 55 and Firefox 51.0a2. Issue is reproducible on v4-dev by going to the collapse docs page and running $('#collapseOne').collapse('show'); in the console before interacting with it.

@bardiharborow
Copy link
Member

bardiharborow commented Nov 21, 2016

After debugging with DevTools, it appears that this.config._parent is "" (the value from Default.parent) if the collapse creation is triggered by$('#collapseOne').collapse('show'); whereas it refers to the #accordion if the collapse creation is triggered by the click handler. This causes the test at js/src/collapse.js#L123 to fail and Item #2 to not be hidden.

@Johann-S
Copy link
Member

I found the same things as @bardiharborow and I'm not sure if we should add a search of a possible parent if no one provided

@pvdlg
Copy link
Contributor

pvdlg commented Jan 14, 2017

The problem is due to unclear documentation. The data-parent has to be set on the collapsible area and not on the trigger. No need to modify the JS code.

Doc fixed here: #21726

@davidtgq
Copy link
Author

Thanks. Here is the fixed code pen: http://codepen.io/anon/pen/YNGNqv?editors=1010#0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants