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

Accordion's "at most 1 open item" invariant gets violated after using JS API #18418

Closed
skateman opened this issue Dec 3, 2015 · 9 comments
Closed

Comments

@skateman
Copy link

skateman commented Dec 3, 2015

Hello!

When you try to collapse/expand accordions with JS, reopening the collapsed accordion by clicking causes expanding both accordions.

See http://getbootstrap.com/javascript/#collapse-example-accordion

animated

Originally posted to: patternfly/patternfly#162

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2015

Collapse's toggle, show, and hide methods are asynchronous. It's not valid to call them twice sequentially like that. You need to wait for the hidden.bs.collapse event before making subsequent calls.

@cvrebert cvrebert closed this as completed Dec 4, 2015
@Johann-S
Copy link
Member

Johann-S commented Dec 4, 2015

This PR would be usefull #17823 😄

@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2015

Indeed! I do intend to get around to that PR, I just have a lot of things on my TODO list.

@Johann-S
Copy link
Member

Johann-S commented Dec 4, 2015

Haha it's ok good luck for your TODO list 😉

@skateman
Copy link
Author

skateman commented Dec 4, 2015

Same happens when I call it like this:

$("#collapseOne").one('hidden.bs.collapse', function () {
  $("#collapseTwo").collapse('show');
});
$("#collapseOne").collapse('hide');

But even if I wait between typing in the two collapse calls.

@cvrebert cvrebert reopened this Dec 4, 2015
@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2015

Perhaps this is related to #17335.

@cvrebert cvrebert changed the title Expanding and collapsing accordions with JS Accordion's "at most 1 open item" invariant gets violated after using JS API Dec 4, 2015
@cvrebert
Copy link
Collaborator

cvrebert commented Dec 4, 2015

This also prompts the question of whether this can be fixed in v3 given that some folks might be relying on the "broken" behavior.

@Johann-S
Copy link
Member

Johann-S commented Jan 6, 2017

IMO we should add data-parent in the collapse element because we allow user to toggle collapse element without passing by the <a> which contain the data-parent attribut.
That's why the collapse behavior is strange because they are no parent

@pvdlg
Copy link
Contributor

pvdlg commented Jan 21, 2017

X-ref #21726

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

No branches or pull requests

5 participants