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.
Problem
- #1168246: Freedom For Fieldsets! Long Live The DETAILS. replaces collapsible fieldsets with the HTML5 details/summary combo, but our collapse.js is not a proper polyfill that achieves a consistent behavior for older browsers.
- Support for the
<details>
element is limited to chrome currently (Compatibility table for support of Details & Summary elements in desktop and mobile browsers)
Goal
- Replace collapse.js with a proper polyfill for details/summary.
Details (irony?)
- The feature detection from http://mathiasbynens.be/notes/html5-details-jquery has been added as a stop-gap fix to collapse.js.
- Available polyfill libraries:
Comment | File | Size | Author |
---|---|---|---|
#40 | ie-11-disclosure-triangle-contrast.png | 68.59 KB | bnjmnm |
Comments
Comment #1
sunComment #2
mgiffordI'm looking for input from @mbrett5062 on this. Really great the things that a modern browser and HTML5 is taking care of.
Comment #3
mbrett5062 CreditAttribution: mbrett5062 commentedJust some quick thoughts/ideas.
I see that Mathias Bynens feature detection that is used by @sun is now in 'modernizer', and also that they are getting close to releasing version 3 which breaks it all up into a pluggable system.
Meanwhile, I have looked over his latest version, and it is much improved, taking the whole thing (detection and polyfill) will be a benefit to us. I commented over on #1168246: Freedom For Fieldsets! Long Live The DETAILS. (Inappropriately).
Here is the link to his code. jquery-details
Comment #4
Gaelan CreditAttribution: Gaelan commentedComment #5
sunComment #6
sunThe change notice for Modernizr mentions a feature detection for details: http://drupal.org/node/1852968
Since the one I copied into collapse.js seems to be the wide-spread-adopted one, we might actually have duplicate JS in core now ;)
Comment #7
mbrett5062 CreditAttribution: mbrett5062 commented@sun the one you copied into collapse.js, was that not from Mathias Bynens? If so that is the one included in modernizer, so your could be removed. I really don't care were it lives, but 1 only is a good idea I think.
Also as I mentioned before, currently in Google Chrome the summary element looks horrible. I know it is browser default styling, but no visual clue that this is clickable is a UX regression for our users, IMHO. If as I stated (and Mathius has done) we do not add the summary as a link, instead just as plane text, that is clickable. Then style all with the same text color as a link and change the cursor to a pointer, this will make all browsers, regardless of support for details, look and feel the same.
Comment #8
ry5n CreditAttribution: ry5n commentedJust like to weigh in that I support styling the details summary to improve affordances. I see no problem modifying the browser default appearance; we do this all the time with CSS on links, buttons, inputs and more, all to improve the experience for users, and
<details>
is no different. It makes sense to me to add the cursor: pointer and make native details consistent across all browsers.Comment #9
jwilson3The default
<details>
on browsers that support it is collapsed; when it is expanded it becomes<details open>
. The only potential problem I see here (from an extremely quick review of a jsbin test) is that with javascript turned off on a browser that doesnt support the details tag, it is just rendered as a paragraph or div or something, so no collapsing. This could present issues for people that need to style things based on whether something is collapsed or expanded. Any CSS styles that target the defaultdetails { /*presume collapsed */ }
will be wrongly styled, and thedetails[open] { /*style expanded */ }
would never be triggered.The issue boils down to whether Drupal 8 still claim to "work" with javascript disabled?
Comment #10
ry5n CreditAttribution: ry5n commented@jwilson We can build the CSS up from the expanded state, like so:
In browsers that don't understand
<details>
, with JS off, this should still work. I’m pretty sure this is how it’s done in core ATM.Comment #10.0
ry5n CreditAttribution: ry5n commentedUpdated issue summary.
Comment #11
Jelle_SI'm not sure if this can be solved with the polyfill that will be created, but states.js also has a regression for browsers that support the details element.
I found this when I was updating the testswarm module:
In browsers that do not support the details element, typing 'expand' in to the textfield, will expand the "details" element, in browsers that do support the details element, nothing will happen.
EDIT:Same story for
#collapsible => FALSE
: Works in browsers that don't support the details element, doesn't work in browsers that do support it.EDIT:
never mind: #1852104: #type details: Remove #collapsible property
Comment #12
sunComment #12.0
sun...added #1858600
Comment #13
suncollapse.js still exists in HEAD. Why? :)
Comment #14
nod_Because everything except chrome.
Comment #15
klonosYeah, but #1252178: Add Modernizr to core is in, so we can use
if (Modernizr.details)
and attach a polyfill to a.no-details
class. No? What is our policy on using polyfills?Comment #16
klonos;)
Comment #17
sunJust dumping some URLs for now, so I can close some browser tabs:
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfill...
http://mathiasbynens.be/notes/html5-details-jquery
https://github.com/mathiasbynens/jquery-details
→ collapse.js is also jQuery.
https://gist.github.com/remy/370590
https://github.com/manuelbieh/Details-Polyfill
https://github.com/termi/Element.details
https://github.com/kapitancho/logifill-details
Comment #18
nod_Nice, but that that important.
Comment #19
Wim Leerss/that that/not that/? :)
Comment #20
mgiffordThere is also this link here that should be considered when we write this polyfill:
http://accessibleculture.org/articles/2012/03/screen-readers-and-details...
Comment #21
jwilson3^ The author of that post claims that he himself cannot find a use case for having a link nested inside a summary. I would be of a mind to just allow it (since the html5 spec currently does) but not to take any opinion on it, or to go out of our way to write or customize our own polyfill that somehow handles the special case. Basically, take the stance of "you're shooting yourself in the foot if you do this, so if you're sure you want to do that, you can also handle the consequences".
So at most, this concern becomes a candidate documentation issue, something as simple as a note along the lines of:
Comment #22
star-szrThat sounds very sensible.
Comment #23
mgiffordAgreed, thanks @jwilson3.
Comment #25
FatherShawnLooking through the list in #17, I found a lot to recommend https://github.com/kapitancho/logifill-details. Since we our Modernizer script already tests for details support, I tweaked Marian's script to use Modernizr, and it's working well supporting a D8 custom template in FireFox, IE 11 and Edge: https://github.com/FatherShawn/logifill-details
Comment #26
droplet CreditAttribution: droplet commentedI don't think we should always push Drupal to an area that looks like more HTML5 friendly but actually it's not. Drupal is going to be a bigger boat. Details even not supporting by 2 big brother. Firefox is the one we all known they always does good things. But they didn't on the list.
http://caniuse.com/#search=details
1. Do Drupal really needed Details tag? Or Details like features only. If latter, we do it in CORE already.
2. Do Drupal going to support fully Details tag ? Or part of features drupal needed only. If latter, we do it in CORE already.
3. Elevate the lib we going to be picked is really fully support Details. If there's one, let's move on. If no one, I think we should consider what features in Details we really needed for CORE now and do it.
Comment #27
mgiffordDetails was needed for accessibility. That's not the only reason it was done, but fieldsets can't be nested and despite Firefox's failure to get onboard with this, it is the right pattern.
Here's the firefox bug. Would be good for folks here to +1 this getting into this popular browser:
https://bugzilla.mozilla.org/show_bug.cgi?id=591737
Comment #28
catchReading that issue, support is already in the firefox codebase, but it's not enabled yet (has to be enabled with a preference explicitly):
https://bugzilla.mozilla.org/show_bug.cgi?id=591737#c265
So potentially not too far off
Comment #29
droplet CreditAttribution: droplet commented@mgifford,
Thanks for the info. I'm not familiar with accessibility. But when I working on #2493957: Add back errors support to native HTML5 details tag, I found current CORE (non-patch) provided more info than native Details tag. eg. it added Show/Hide:
Will screen reader given extra hints on native Details automatically ?
https://html.spec.whatwg.org/multipage/forms.html#the-details-element
Reading this ref, there's 1 thing missing in Drupal:
- a `toggle` event.
I don't see any ref in SPEC but Chrome does it:
- handle SPACE key
Our collapse.js is a Polyfill lib already. We can do it further to move main code out of Drupal.behaviors.
(Noted that: No libs in above list supporting `toggle` event)
Comment #30
mgiffordThanks @droplet - I've been looking for time to dig into this and just not finding it.
From what I recall, we did test this behavior to verify that it was read out properly by a screen reader, but don't have the issue handy.
There are other docs on other approaches:
http://html5doctor.com/the-details-and-summary-elements/
https://mathiasbynens.be/notes/html5-details-jquery
I'm not a JS guy, so not sure what our options are. We can also leverage Drupal.announce() to announce this information.
Comment #31
FatherShawnNative support for details-summary in FireFox is slated for v.49 - September 2016: https://bugzilla.mozilla.org/show_bug.cgi?id=591737#c275
Comment #33
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedNative support for details/summary was indeed turned on by default in Firefox 49, and I've confirmed it works when JS is disabled.
The native Firefox 49
<details>
seems to be implemented using ARIA roles, states and properties; just like Chrome/Opera (and Safari? I think it was introduced before the Blink fork).The native Firefox behaviour matches our own
collapse.js
:- The
<summary>
element has arole=button
attribute (and is announced as such).- When focussed, the summary element responds to enter and spacebar key presses.
-
aria-collapsed
ANDaria-pressed
state attributes are present on the element, and are updated when the<details open>
state changes.- The
<summary>
element has anaria-controls
attribute, pointing at the parent<details>
element.This leaves IE and Edge as the only major browsers which don't support
<details>
. It's currently "under consideration" for Edge, but I don't think we can expect it in any version of IE.Comment #35
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commenteddetails element is now "in development" for Edge.
Comment #36
mgiffordSoon it will just be legacy Microsoft & Opera-mini bucking this whole HTML5 fad http://caniuse.com/#feat=details
:)
Comment #40
bnjmnmSomething I discovered while working on #3037121: Disclosure triangle is missing in details/summary groups in off-canvas dialog in Firefox. Due to
collapse.js
using an indifferent-to-font-color .png for the disclosure triangle, there are contrast issues with<details>
on dark backgrounds.Comment #42
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedThis issue is very outdated, and has a lot of points which need to be verified again. I'll go through it in detail later, but here's a quick brain-dump of some things that need to be clarified....
open
attribute by looking for a dimension change, IIRC.Comment #43
tim.plunkettFrom #3037121-10: Disclosure triangle is missing in details/summary groups in off-canvas dialog in Firefox:
Comment #49
mherchelNot sure if we can close this quite yet, but I just opened up #3272425: Remove Details Aria Polyfill for Drupal 10 to remove all of this stuff.
Comment #53
mgiffordComment #54
bnjmnmCollapse.js was removed in Drupal 10 #3269082: Remove HTML5 details collapse polyfill, so this is only relevant to Drupal 9.
Technically this is a valid issue until Drupal 9 hits EOL 6 months from now in November 2023, although I have my doubuts keeping it open will result in much. It would mean devoting energy towards finding a better alternative for a not-ideal-but-toally-fine polyfill that only impacts IE11 users... for a version that will be EOL in half a year.
But perhaps my outlook will inspire some heroism.
Comment #55
longwaveDrupal 9 is EOL and all supported browsers support the details element natively now.