Problem/Motivation

We have a polyfill that supports collapsing the HTML5 details element in browsers that do not support it natively.

All modern browsers support the details element now so we can remove the polyfill.

Steps to reproduce

Proposed resolution

Remove the polyfill code.
Remove all CSS and JS around the collapse-processed and details-title classes as these are now obsolete.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

In Drupal 10 the details HTML tag is available in all supported browsers and the supporting code for Internet Explorer will be removed.

Issue fork drupal-3269082

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

Status: Active » Needs review

There was a surprisingly large amount of code and CSS to support this feature.

longwave’s picture

Issue summary: View changes
longwave’s picture

When committing please credit @kostyashupenko from the parent issue as parts of their patch were borrowed here.

mherchel made their first commit to this issue’s fork.

mherchel’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +JavaScript

Updated the branch.

Looked through the MR, and all of the changes look good! This is a pretty large MR, so if it might be more manageable to create followups for each theme instead of tackling everything in this one commit.

That being said, I'll let the core committer make that decision, as everything that I tested here looks perfect.

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work

There are multiple @todo items pointing to #2981732: Add prefix to Modernizr configuration, aside from that issue being closed anyway, the changes this issue would have been the ones to make those todos irrelevant, so they should get removed in this issue's scope.

Setting to NW for visibility - I'm still reviewing but don't expect to find much, this looks pretty good.

Having all the theme changes here seems fine - referencing the changes in one theme to contextualize the other actually makes the review a little easier.

andregp’s picture

Status: Needs work » Needs review
FileSize
7.01 KB
57.42 KB

@bnjmnm Does this address your comments? If so I can commit these changes to the MR.

bnjmnm’s picture

+++ b/core/themes/claro/css/components/system-status-report.pcss.css
@@ -54,17 +54,6 @@
-.details .system-status-report__status-icon--error:before {
-  background-image: url(../../images/core/e32700/error.svg);
-}
-.details .system-status-report__status-icon--warning:before {
-  background-image: url(../../images/core/e29700/warning.svg);
-}

Did you check to see if removing this and other .details style doesn't cause unwanted effects. There's a good chance the styling should still be there - it just can't rely on a class that won't be provided once Modernizr goes away.

andregp’s picture

@bnjmnm I didn't... I though that once Modernizr is removed these styling would not be applied anywhere (since there wouldn't be any element with .details class anymore), so I just removed them.
I though about removing just the .details part from the selectors, but I wondered if this wouldn't cause the style to be applied on other undesired elements (like for e.g. being applied to all elements with .system-status-report__status-icon--error:before class, etc).
Should I search for a class to substitute .details?

bnjmnm’s picture

Re #11 I'm guessing you can just remove .details, but would need to manually test to be sure. I suspect it was there to add these styles only if <details> elements are supported. In D10 all supported browsers work with <details>, so I assume it simply isn't necessary.

A class like .system-status-report__status-icon--error is (intentionally) a very specific selector that does what it says. It is named using the BEM methodology and it's all but guaranteed any class with that name wants to be styled the same.

The best way to know if this works correctly is go to the system status page and compare screenshots before/after the patch - and make sure there isn't a .details class in <html> post-patch. It should look the same. If icons are suddenly missing this means something likely got removed that should have been modified

longwave’s picture

Status: Needs review » Needs work

The icons still show, because there is a fallback in system.admin.css, but they are not quite correctly aligned.

It is also tricky to test because Modernizr is still loaded on the system report page and so the <html> tag still has the details class applied.

+++ b/core/themes/claro/templates/details.html.twig
@@ -21,8 +21,6 @@
-  @todo Remove prefix after https://www.drupal.org/node/2981732 has been solved.

We haven't removed the prefix, so should we be removing the todo?

longwave’s picture

Status: Needs work » Needs review

Pushed a commit that removes the .details class. Also cleans up what seemed to be a minor bug in both Seven and Claro where the LTR version used the icon class, but the RTL version used the title class instead. As this is all icon related I changed both to use the icon class; both classes are applied to the element in question, and system.admin.css also uses icon in both cases, so this just seems better for consistency.

I want to do some more testing on collapse.es6.js before removing the code that opens fragments automatically; I couldn't get this to work properly.

longwave’s picture

Seven's system-status-report.css still has this slightly cryptic bit of CSS:

/* Make poly-filled details and summary elements behave correctly. */
.system-status-report summary:first-child ~ * {
  display: none;
}
.system-status-report details[open] > *,
.system-status-report details > summary:first-child {
  display: block;
  color: inherit;
}

I think this can be safely removed now, but not entirely sure?

longwave’s picture

Re: collapse.es6.js, I think this needs to stay. formFragmentLinkClickOrHashChange is a custom event fired by form.js when a link is clicked on the same page that contains a fragment. There is an argument for refactoring it into form.js itself I think, given that it is effectively one line. I guess some functional JS test coverage would be useful here :)

Status: Needs review » Needs work

The last submitted patch, 9: 3269082-9.patch, failed testing. View results

longwave’s picture

Status: Needs work » Needs review

Hiding #9, the MR is the thing to review again.

bnjmnm’s picture

Issue tags: +Needs screenshots

Re #13

We haven't removed the prefix, so should we be removing the todo?

A few things led me to conclude that we may as well remove the todo (also glad you're asking for clarification 🙂):

  1. Partially because the issue it is referencing was marked "Closed - won't fix" #2981732: Add prefix to Modernizr configuration
  2. Changing those classes now could cause style regressions on sites, which could be an acceptable change in a major release if it were a needed change, but theme-specific classes are quite common.
  3. It would be a particularly odd change, since Modernizr added the .details class to <html>, and un-prefixing these would then move it to the <details> elements. If all the themes switch to a .details class, the css can just target the <details> element.

I think screenshots of the system settings page before/after and RTL would be helpful. I often remind users not to clog an issue with redundant/unnecessary screenshots... but right now I'm officially stating "this could use some screenshots", and I invite the screenshot-inclined to hook us up.

Wim Leers’s picture

What's the next step here? 😊

longwave’s picture

Status: Needs review » Needs work

Someone to make some screenshots as requested in #19, and ideally someone to understand what the CSS in #15 does and whether it can be removed now.

longwave’s picture

Rebased against 10.0.x.

bnjmnm’s picture

Re #15
This CSS can be removed

/* Make poly-filled details and summary elements behave correctly. */
.system-status-report summary:first-child ~ * {
  display: none;
}
.system-status-report details[open] > *,
.system-status-report details > summary:first-child {
  display: block;
  color: inherit;
}

But there will be a small regression unless this is added:

.system-status-report summary {
  display: block;

}

Without this, the summary element uses the default display value of list-item, which results in making the hidden disclosure arrows visible

nod_’s picture

Issue summary: View changes
Issue tags: +9.4.0 release notes, +Needs change record

added release note

nod_’s picture

took a stab at writing the change notice

longwave’s picture

Change notice looks fine to me. This isn't going into 9.x, so retagging for 10.0.0 release notes.

MR needs rebasing and the MR comments and #23 still need addressing.

kostyashupenko made their first commit to this issue’s fork.

catch’s picture

Priority: Normal » Critical

This is the last remaining blocker to deprecating modernizr, which we want to do in 10.1.x for removal in 11.x, so bumping to critical.

catch’s picture

Issue tags: +Drupal 10 beta blocker

Replacing the general 'stop using modernizr' issue in #3118149: [meta] Requirements for tagging Drupal 10.0.0-beta1 with this one, so tagging as a blocker. I'm not sure if it'd be fine to just do this in 10.1.x instead, if so we could make it a 'should have'.

Gábor Hojtsy’s picture

catch’s picture

Pretty sure we can just do this in a minor, but leaving as critical since it still blocks modernizr removal.

Spokje made their first commit to this issue’s fork.

Spokje’s picture

Rebased and force pushed MR

nod_’s picture

Title: Remove HTML5 details collapse polyfill » [PP-1] Remove HTML5 details collapse polyfill
Status: Needs work » Postponed

soft postponed on #3110137: Remove Classy from core that will make this easier.

bnjmnm’s picture

Status: Postponed » Needs review
Issue tags: -Needs screenshots

Updated the MR, which is much smaller with Classy/Bartik/Seven removed.

bnjmnm’s picture

Title: [PP-1] Remove HTML5 details collapse polyfill » Remove HTML5 details collapse polyfill
mherchel’s picture

Status: Needs review » Needs work

This is looking really good. I have some questions/concerns about the remaining collapse.js file

in #16, @longwave states

Re: collapse.es6.js, I think this needs to stay. formFragmentLinkClickOrHashChange is a custom event fired by form.js when a link is clicked on the same page that contains a fragment. There is an argument for refactoring it into form.js itself I think, given that it is effectively one line. I guess some functional JS test coverage would be useful here :)

However in this MR's version of the file, the event now references a function that was removed in the MR. This will result in a console error. Note that the formFragmentLinkClickOrHashChange event also gets referenced in vertical-tabs.js

In an MR comment (below #22) @nod_ suggested

I'd put those few lines in a new file called details.js. collapse is D6-era naming for this feature. Renaming would keep related files next to each other in the folder

This is not yet done, however I'm still unclear on the need for leaving collapse.js/details.js

I'm going to reach out to @nod_ in Slack to ask him to comment/clarify.

Other than the JS issue, this looks RTBC to me. I tested both Claro and Olivero's details elements, in addition to testing the status report styles within Claro (of which the styles were modified).

mherchel’s picture

FileSize
305.08 KB

Note that you can see the console error in action on the status report page

bnjmnm’s picture

Status: Needs work » Needs review

Re #38: looks like more got ripped out than there should have been. MR updated

longwave’s picture

ElementsVerticalTabsTest still refers to the now-removed collapse.js. The comment reads:

   * Ensures that vertical-tabs.js is included before collapse.js.
   *
   * Otherwise, collapse.js adds "SHOW" or "HIDE" labels to the tabs.

However this functionality was provided by the now-removed polyfill, so I think this test can be safely removed.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

thanks for the file rename. Everything looks in order.

  • lauriii committed 9ad9131 on 10.1.x
    Issue #3269082 by longwave, Spokje, mherchel, andregp, kostyashupenko,...

  • lauriii committed e72233a on 10.0.x
    Issue #3269082 by longwave, Spokje, mherchel, andregp, kostyashupenko,...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -10.0.0 release notes

It's nice to see how much simpler this issue has evolved over time 🤩

Committed 9ad9131 and pushed to 10.1.x. Also cherry-picked to 10.0.x. Thanks!

I'm not sure we actually need a release-note for this, but I did publish the CR. We will have a generic release note about the changed browser support which should cover this as well.

Status: Fixed » Closed (fixed)

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