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

Nested accordion inherits parent's flush styling #37455

Closed
3 tasks done
Ylaana opened this issue Nov 8, 2022 · 2 comments · Fixed by #37508
Closed
3 tasks done

Nested accordion inherits parent's flush styling #37455

Ylaana opened this issue Nov 8, 2022 · 2 comments · Fixed by #37508

Comments

@Ylaana
Copy link

Ylaana commented Nov 8, 2022

Prerequisites

Describe the issue

When nesting a 'regular' accordion inside an accordion with the .accordion-flush class, it inherits the flush styling. I'd expect the nested accordion to retain the default styling.

Reduced test cases

https://codepen.io/ylaana/pen/OJEWJYM

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

v5.2.2

@vardhanreddy27
Copy link

It sounds like you are experiencing an issue with the styling of nested accordions in the Bootstrap library.

By default, accordions in Bootstrap use a "card" style, which includes a box shadow and some padding around the accordion content. The .accordion-flush class removes this styling to create a "flush" accordion, which has no padding or box shadow around the content.

If you nest a "regular" accordion (i.e. an accordion without the .accordion-flush class) inside a flush accordion, the inner accordion will inherit the flush styling due to the way CSS works. This is because the inner accordion is a descendant of the outer flush accordion, and the styles applied to the outer accordion will also be applied to its descendants unless they are explicitly overridden.

One way to avoid this issue is to add a wrapper element around the inner accordion and apply the .accordion class to the wrapper instead of the inner accordion itself. This will allow you to apply different styles to the inner and outer accordions without affecting each other.

For example:
5CE9E88E-D390-4239-9BD4-5293C1CC4609

@MXMLN-sec
Copy link

One way to avoid this issue is to add a wrapper element around the inner accordion and apply the .accordion class to the wrapper instead of the inner accordion itself. This will allow you to apply different styles to the inner and outer accordions without affecting each other.

For example: 5CE9E88E-D390-4239-9BD4-5293C1CC4609

I'm not really sure what you ment with the wrapper element.
An Accordion in Bootstrap already has a wrapper with the vlass accordion <div class="accordion">.

And adding the same wrapper again like below won't make any sense and also won't resolve the problem.

<div class="accordion">
  <div class="accordion">
    <!-- inner regular accordion -->
    ...
  </div>
</div>

@mdo mdo added this to v5.3.3 Nov 16, 2023
@github-project-automation github-project-automation bot moved this to To do in v5.3.3 Nov 16, 2023
@mdo mdo added the has-pr label Nov 16, 2023
@julien-deramond julien-deramond moved this from To do to Review in progress in v5.3.3 Nov 17, 2023
@github-project-automation github-project-automation bot moved this from Review in progress to Done in v5.3.3 Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants