Problem/Motivation

Apply accordion styling to HTML element details
example: https://getbootstrap.com/docs/5.3/components/accordion/

Proposed resolution

Update '/bootstrap5/templates/form/details.html.twig'

Issue fork bootstrap5-3337643

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jannakha created an issue. See original summary.

vaibhav_arora’s picture

StatusFileSize
new1.12 KB
new31.3 KB

I have added fixes and created patch for the above HTML element border issue, and also attached the screenshot for reference.

vaibhav_arora’s picture

Status: Active » Needs review
abyss’s picture

Assigned: Unassigned » abyss
Status: Needs review » Active

1. It is INCORRECT to change styles in dist, as it contains clean files from the Bootstrap theme.
2. It is not correct to update styles only in the css file, as they will be overwritten after compiling the scss styles.
3. You should update not the details component with the class "card", but the summary tag with the class "card-header".

abyss’s picture

Status: Active » Needs work

@VladimirAus & @jannakha, a question for you, maybe we should update the details.html.twig template, because at the moment this template uses classes of the card component, although it looks and performs the functionality of the accordion component.
Or is it simple to update the styles for the summary tag of this template?

abyss’s picture

Assigned: abyss » Unassigned
ravi kant’s picture

StatusFileSize
new68.07 KB
new96.56 KB

@abyss if border class 'border-0' will be added directly on details.html.twig then the border of details will be removed. The issue is on collapse due to the summary tag having a border that should remove when the details tag closes so I have created a patch according to it.

ravi kant’s picture

Status: Needs work » Needs review
abyss’s picture

Status: Needs review » Needs work

@ravi kant

  1. Let's wait for a response from the maintainers, because we may need to update the template for details.
  2. While we wait, could you please update your patch as it:
    • Not applicable, as it has the wrong path (the path should be from inside the bootstrap5 theme)
    • There is an obvious problem with compiling the styles, as most of the changes are just whitespace.
  3. Also, please pay attention to my previous comments, I described exactly the problem with the summary tag, as well as the incorrect choice of component classes that were applied to the details tag.
ravi kant’s picture

StatusFileSize
new96.1 KB

@Abyss

Adding new patch but whole style files is updated for white space. I have checked with 'sass scss/style.scss css/style.css' and 'npm run build:sass'.

abyss’s picture

Status: Needs work » Needs review
StatusFileSize
new341.14 KB
new34.55 KB

Removed the border for the summary tag.

ravi kant’s picture

@Abyss
The patch is not applying.

abyss’s picture

StatusFileSize
new42.59 KB

Very strange. I double-checked the patch and everything seems to be working correctly.
@ravi kant could you tell us what you used to apply the patch?

ravi kant’s picture

StatusFileSize
new96.6 KB

@abyss
Copied patch in theme root and apply patch from theme root in terminal using following command.
git apply patch_file.patch

abyss’s picture

@ravi kant what version of the theme do you use? 3.0.x-dev?
Because styles are a very delicate thing, and a patch that may apply to one version will not apply to another.

ravi kant’s picture

@Abyss
The version is Bootstrap5 3.0.8.

boddy’s picture

Status: Needs review » Reviewed & tested by the community

the patch was applied on the 3.0.x-dev and 3.0.8
RTBS

bobi-mel’s picture

The patch was successfully applied on the 3.0.x-dev

jannakha’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
StatusFileSize
new43.29 KB

this issue is not fixed, see screenshot:

jannakha’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new139.96 KB
new34.32 KB

Patch is in MR

Closed:

Open:

vladimiraus’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for MR! 🍰
Looks great!

jannakha’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new86.64 KB
new19.41 KB

ok! here's a proper solution I think!

- as per #5 by @Abyss - yes, you're correct the template needs to be updated
- I have started moving to CSS variables so we can have good things (like dark mode) and actually implementing things the Bootstrap5 way (now that they're moving to CSS variables too)

checkout MR49 - https://git.drupalcode.org/project/bootstrap5/-/merge_requests/49/diffs

HTML component now looks like Bootstrap accordion:

this also will solve issue:
https://www.drupal.org/project/bootstrap5/issues/3380986

vladimiraus’s picture

Status: Needs review » Reviewed & tested by the community

Looks good! 🧁

  • VladimirAus committed 234ada25 on 3.0.x
    Issue #3337643 by jannakha, Abyss, ravi kant, vaibhav_arora, VladimirAus...
vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thank you! Committed! 🍻

  • VladimirAus committed 291cb360 on 4.0.x
    Issue #3337643 by jannakha, Abyss, ravi kant, vaibhav_arora, VladimirAus...

  • VladimirAus committed 234ada25 on 4.0.x
    Issue #3337643 by jannakha, Abyss, ravi kant, vaibhav_arora, VladimirAus...
vladimiraus’s picture

  • VladimirAus committed 6a4505a4 on 3.0.x
    Issue #3337643 by jannakha, Abyss, ravi kant, vaibhav_arora, VladimirAus...

  • VladimirAus committed b9d060b8 on 4.0.x
    Issue #3337643 by jannakha, Abyss, ravi kant, vaibhav_arora, VladimirAus...

  • VladimirAus committed 6a4505a4 on 4.0.x
    Issue #3337643 by jannakha, Abyss, ravi kant, vaibhav_arora, VladimirAus...
n-i’s picture

details.card>summary.card-header {
    border-radius: $border-radius;
    border-bottom: 0;
}

details.card[open]>summary.card-header {
    border-bottom: $card-border-width solid $border-color;
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}
jannakha’s picture

Version: 3.0.x-dev » 4.0.x-dev

still an issue in v4

jannakha’s picture

Title: HTML element DETAILS is rendered with extra border on the bottom » Apply B5 accordion styles to HTML element deatils
Assigned: Unassigned » jannakha
Category: Bug report » Task
Issue summary: View changes

jannakha changed the visibility of the branch 3337643-html-element-details to hidden.

jannakha changed the visibility of the branch 3337643-html-element-details to active.

jannakha changed the visibility of the branch 4.0.x to hidden.

jannakha changed the visibility of the branch 3.0.x to hidden.

jannakha changed the visibility of the branch 3337643-html-element-details to hidden.

jannakha’s picture

Assigned: jannakha » Unassigned
Status: Needs work » Reviewed & tested by the community

moved MR to v4
accordion styles apply cleanly to details

thanks @Abyss 🇺🇦

jannakha’s picture

Title: Apply B5 accordion styles to HTML element deatils » Apply B5 accordion styles to HTML element details

jannakha’s picture

Status: Reviewed & tested by the community » Fixed

merged to dev
thanks for your contribution

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

stefan.korn’s picture

This changes breaks Drupal core's "vertical tabs" element: https://www.drupal.org/docs/develop/user-interface-standards/vertical-tabs

For example: Edit a node in Bootstrap5 theme, and see the difference between Bootstrap 4.0.7 and 4.0.8.

The "vertical tabs" element is relying somehow on a direct details descendent in its js:

$this.find('> details')

At this moment I see no easy fix for this, despite reverting this change.

I am also not exactly sure, whether this change really aligns with Bootstrap.

The details element is a special HTML element: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/det...
From my understanding this is providing a collapsible element directly via the Browser, no need for a framework or something like that.

Bootstrap itself has no reference to the details element as far as I can see. Accordion is an own component, that goes beyond what a simple details element would provide.

In that sense I would not see the necessity to wrap a details element inside a Bootstrap accordion like it is done with this change. Imho the details element could stay like it is and if someone needs/wants an accordion, they should just render a bootstrap accordion.

If one really want to style details like accordion, maybe one could choose just to apply styling like accordion to details, but not adding the Bootstrap accordion functionality on top of a details element.

jannakha’s picture

there's an temporary patch for that here - https://www.drupal.org/project/bootstrap5/issues/3574890

semantically details should not be used on these types of elements: ref

proper solution will be implementing vertical tabs like Claro does in Bootstrap 5 style issue #3576867