Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How to reproduce:
- Open any page with "details" HTML element on it (using Firefox 47.0), for example Performance page (/admin/config/development/performance)
- Click by headings: "Bandwidth optimization" or "Caching" or "Clear cache"
- Expected result: Area below clicked heading should be collapsed
- Current result: Nothing happend
Alternative way how to reproduce:
- Install Field Group module (https://www.drupal.org/project/field_group)
- Add new field group type "Details" to some node display (on Manage display page)
- Place to field group "Details" some fields
- Go to node display page using Firefox 47.0
- Click by added field group type "Details" title
- Expected result: Area below clicked title should be collapsed
- Current result: Nothing happend
Everything works fine if use Chrome browser.
This issue appears because:
- Firefox not fully supported "details" HTML element: https://bugzilla.mozilla.org/show_bug.cgi?id=591737#c265
- JS file /core/misc/collapse.js not correct handle this situation:
- It not setup initial state (expanded/collapsed) for section inside details element
- It try .toggle() CollapsibleDetails JS object instead of section inside details element
Firefox 49 released with support of https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details
Comment | File | Size | Author |
---|---|---|---|
#18 | details-wrapper.patch | 1.09 KB | droplet |
#17 | 2792593-details_collapse_in_firefox_2.patch | 565 bytes | Antonnavi |
Comments
Comment #2
AntonnaviComment #3
AntonnaviComment #4
andypostComment #5
droplet CreditAttribution: droplet commentedWe have patch for a while:
#2493957: Add back errors support to native HTML5 details tag
Comment #6
AntonnaviThank You for review andypost and droplet!
Re-open this issue because patch listed in:
#2493957: Add back errors & summary support to native HTML5 details tag
Not solve my issue. After apply it have the same issue with no reaction (expand/collapse) by click "details" HTML elements in Firefox 47.0 (Ubuntu).
Comment #7
droplet CreditAttribution: droplet commentedtagging for Ubuntu testers. I can't reproduce it with FF48 in Windows & Mac.
By the way, I'm interesting on this point. Any side effects? Can you explain a bit more.
Comment #9
AntonnaviThank You for review, droplet!
Here I mean code:
If add
console.log(this);
inside onLegendClick function You will see:CollapsibleDetails { $node={...}, $summary={...}, setupSummary=function(), more...}
Means:
.toggle()
applied to CollapsibleDetails object and call:But inside
toggle()
function not available code that will handle show/hide<section>...</section>
area for browsers that not fully support<details></details>
tag.Full support of
<details>
and<summary>
elements will be added in Firefox 49 https://developer.mozilla.org/en-US/Firefox/Releases/49#HTMLCurrently in Firefox 47.0 (Ubuntu 15.10)
<details>
and<summary>
elements not works correct.Comment #10
jibranWe can add JS tests for this now.
Comment #11
Antonnavijibran, can you plz provide some HowTo/article about how to create/write JS tests.
Comment #12
andypost@Anton there's https://www.drupal.org/node/2716803 and https://www.chapterthree.com/blog/javascript-testing-comes-to-drupal-8
But I'm sure there's no way to test this issue with phantom cos it based on Chromium but the bug in FF47(48)
So only manual testing possible
PS: slimerjs is a FF based tests but have no integration with Drupal
Comment #13
droplet CreditAttribution: droplet commentedIf #9 really a bug in Firefox (Ubuntu), pretty much things will be broken (not just Drupal) and I believe there's will be a 47.0.1 or so to fix it immediately.
I loaded up my Ubuntu box and do not find the problem. Please update the Issue Summary to reflect the exact problem (Core Only). Thanks!
Comment #14
AntonnaviStrange thing, after update to latest version 8.1.9 details element works correct on Firefox 47.
Will research a bit more what was an issue reason.
droplet, thank You for review and help!
Comment #15
AntonnaviThis issue appears because:
As we can see CSS expects some HTML element wrapper (around details area content) with "details-wrapper" CSS class. If we check
core/themes/stable/templates/form/details.html.twig
template file code(this template used for output details element if used theme not define own details.html.twig template file):
As we can see in this file not available some wrapper (with "details-wrapper" CSS class) around "errors", "description", "children", "value" items. From this reason (if used this template file) details element will not works correctly in browsers that not fully support details element.
In admin themes this issue not appears because Bartik and Seven themes use as base theme Classy theme that define own details.html.twig template file with code:
As we can see here available
<div class="details-wrapper">...</div>
element and details element works correct in any browser.For fix this issue we should add
<div class="details-wrapper">...</div>
wrapper around "errors", "description", "children", "value" items incore/themes/stable/templates/form/details.html.twig
template file. Attached patch add this wrapper.Comment #17
AntonnaviComment #18
droplet CreditAttribution: droplet commentedGood catch!!
Comment #19
andypost+1 to fix both themes, but how that fits in our BC policy
Suppose Cottser should decide
PS: FF 49 released
Comment #20
andypostProper status
Comment #21
andypostComment #23
AntonnaviForce tests re-run
Comment #24
AntonnaviTests pass-ed: Return RTBC status
Comment #25
alexpottComment #26
star-szrI think this would generally be okay to fix in core/stable although there is some risk there so it probably couldn't go into 8.2.x. My concern is how to avoid breaking it again. I think this div was removed because it looked like it wasn't needed. #2407725: Remove classes from system templates d*.html.twig.
And to be clear, this is only in (now slightly older) versions of Firefox, correct? Maybe the issue should be re-titled if so.
I'm wondering if a different approach would be possible using
<details>
feature detection via Modernizr - we already have<details>
detection in our Modernizr build. Any page with a<details>
element would have adetails
orno-details
class on thehtml
element. I don't fully understand the issue though, so this may not be possible.Comment #27
droplet CreditAttribution: droplet commentedBefore my patch #18, I thought using JS to guarantee that with wrappers. However, it's Performance issue for render & I thought all these HTML code are the "Details Pattern"
Comment #28
droplet CreditAttribution: droplet commentedThemers should be acknowledged that a polyfill layer and theme it correctly. Don't repeat #2407725: Remove classes from system templates d*.html.twig mistakes in contributed themes.
with or without Native Details. It's a pattern I meant. We theming with it (considered as a container DIV), eg: in Seven theme, we do it:
Comment #29
AntonnaviThank You for review Cottser and droplet!
It is not only about Firefox 47.0, it's about any browser that not fully support
<details>
HTML element. As noted in comment #15 if user use browser that not fully support<details>
HTML element used:files for handle this situation and make
<details>
works.More detailed about logic in comment #15.
Comment #30
star-szrI spoke to @lauriii about this at BADCamp. I was reaching for something like a js- prefixed class but forgot that it's essentially just a hack for data attributes.
So to make this more explicit and less likely to break in the future, how about we…
<div data-details-content>
with a Twig comment above explaining that the wrapper is for browsers that don't natively support<details>
. Everything but core and stable will keep the existing details-wrapper class.Comment #31
droplet CreditAttribution: droplet commentedChange to different styling attributes seems wrong direction. Created another layer for anyone. (It will cause a lot of changes in JS also.)
Theoretically, .details-wrapper isn't totally part of JS script (collpase.js). Turned JS off, we still maintain the same style.
We should look into all usages in CORE, not this single component with bug.
Comment #32
star-szrThanks for the feedback. The point of using a data attribute here is that we basically have a policy that frontend devs massaging markup know not to remove data attributes. A class without a js- prefix is usually fair game to be removed.
I tested and doing that requires no JS changes, only minor CSS changes. I can put up a patch if you like.
I don't quite follow, can you expand on that thought?
Comment #33
droplet CreditAttribution: droplet commentedThanks
It's interesting new stuff to me. However, it won't help someone like me never know it before. Nevermind, it seems not in this scope.
I thought a Twig comment is enough. Must I miss the point? (If you could make a patch for #30, that may help to understand)
Searching the CORE files, there're 45 matches of .details-wrapper. It's not good to rename or adding another new identity to deal with it.
Comment #35
droplet CreditAttribution: droplet commentedIt may blocking #2880703: Status report page without JavaScript is messed up
Furthermore,
this is a bug report. #30.1 and #30.3 is a new feature request to enhance the component I thought. We should add a follow-up for that.
`data-details-content` affected the way to use JS API (Or CSS coding)
Comment #45
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Following the steps to replicate this from the IS and I was not able to get the issue. Using the latest version of firefox and chrome.
Are there additional steps or is this no longer an issue?