Important follow-up to #2854624: Details and accordion update based on Seven Style Guide. There is a WCAG failure at level A.

Problem/Motivation

The details/summary elements in Seven theme have inconsistent focus styles across different browsers (some show a focus indicator, others don't).

In some browsers (Chrome + Opera on Mac) the summary element has an underline when it is focused, but in others it doesn't (Safari on Mac, others...?). I noticed this halfway though manual testing of the long list of OS/browser combinations we support, and didn't go back to check them all over again ;-)

We MUST HAVE a clear visual focus style for the summary element.

  • In the case where the focused summary DOES NOT get an underline, the ONLY indication is a slight colour change. This is a failure of WCAG 1.4.1 Use of Color (level A). The focus state is essential information, and it is being conveyed by colour alone.
  • Since the colour change on focus is so slight, it's also a failure of WCAG 2.4.7 Focus Visible (~borderline ...) and 1.4.11 Non-text contrast (both level AA).
  • Now, Proposal: A Style Guide for Seven doesn't actually have a focus style for the summary element. We definitely need to make summary focus visible in all browsers, so lets investigate an fix that in a follow-up.

    Major, because it is currently a level A WCAG failure in affected browsers.

    Proposed resolution

  1. Must-have: Ensure all browsers (including mobile phone browsers) indicate when the summary element is focused.
    The simplest approach is to make the underline-on-focus style work in all of our supported browsers. No design work is needed to satisfy WCAG 2.0 SC 2.4.7 "Focus Visible".
  2. Could-have: The seven style guide doesn't have a focus style for summary elements, so we may want to create one.

Remaining tasks

Investigate:

  1. Which browsers show focus, and which ones don't?
    • Firefox 64 (mac, linux) - shows focus, OK.
    • Chrome 71 (mac, linux), 73 (mac) - does not show focus.
    • Opera 57 (mac, linux) - does not show focus.
    • Safari 12 (mac)- does not show focus.
    • IE11 ?
    • Edge ?
    • Chrome (android) ?
    • Safari (iOS) ?
  2. Find out underlying cause - selectors?

User interface changes

Accessibility fix. Complete details/summary styling in Seven theme, so all browsers indicate when the summary element has focus.

API changes

none

Data model changes

none

Comments

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

The must-have part of this can be addressed by making the underline-on-focus work in all browsers.

andrewmacpherson’s picture

Title: Details/Summary focus style is broken/missing in some browsers. » Seven theme's details/summary focus style is broken/missing in some browsers.
Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jrockowitz’s picture

The details summary:focus is being removed in core/themes/seven/css/base/elements.css line 163.

details summary:focus {
  outline: none;
  text-decoration: underline;
}

Seems like the below code is trying to underline the details summary but it stopped working in some browsers (for me OSX/Chrome).

Here is the original issue for Seven's details summary focus. #2368393: Fix focus effect on summary details

jrockowitz’s picture

jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new424 bytes

The attached patch removes the details summary:focus. style from the Seven theme and switches back to the default style. I am not sure this is the best solution but it might be the only solution if some browsers no longer support underlining the details summary.

This JSFiddle shows in Chrome and Safari on OSX that the details summary can no longer be underlined.

I feel our issue is related to When did Chrome start underlining links differently? but I can't find any concrete proof.

jrockowitz’s picture

StatusFileSize
new990 bytes

One workaround if we really want to underline the details summary onfocus is to wrap the summary text in a <span> tag and underline the <span> tag instead of the <summary> tag.

This JSFiddle shows that a span within the summary can be underlined in Chrome & Safari on OSX..

The attached patch is a proof of concept.

kristen pol’s picture

Thanks for the patches. I reviewed the code in both #9 and #10 and they are clear and I don't have any suggested changes. I would leave the decision to which approach is best to @andrewmacpherson or someone else on the accessibility team but I will do some testing of both of these and add some screenshots.

kristen pol’s picture

I tested both patches and see the blue outline from #9 and the underline from #10. In order to continue testing on other browsers, @andrewmacpherson or someone else on the accessibility team should decide which direction to go in.

jrockowitz’s picture

This issue should probably be reviewed by the UX team because the simplest solution is to remove the underline and switch back to using the browser's default behavior and styling for focused details summary.

Adding the extra span tag would be permitted in a minor Drupal release but it feels like a hacky solution. Also, the Seven theme does not have a maintainer, so I am not sure who would make this decision.

Finally, we need to consider that the community is actively working on new Administrative UI theme and the Seven theme is going to be deprecated and replaced.

I do agree with Andrew that this is a major issue and should be resolved ASAP. Removing the custom underline style via the patch from #8 could be backported to 8.6.x. The patch from #9 would most likely have to be only applied to 8.7.x+ because changing the HTML markup for the detail widget could cause some regressions/issues, especially if people have extended the Seven theme.

kristen pol’s picture

I agree with @jrockowitz on the comments in #13. Definitely a UX/A11Y decision. Thanks for the details.

andrewmacpherson’s picture

Issue summary: View changes
StatusFileSize
new121.87 KB

Thanks for the patch @jrockowitz, and the screenshots @Kristen.

I updated the list of affected browsers. It seems none of the Webkit/Blink browsers are working now, but in my original report I said Chrome was working and Safari wasn't. Maybe something has changed in Blink?

What is the span for in #10 - to make the selector more specific, or something else? I haven't been able to figure out the cause.

the simplest solution is to remove the underline and switch back to using the browser's default behavior and styling for focused details summary.

The problem with this approach is the user-agent focus styles differ considerably. The IE/Firefox approach of a 1px dotted line isn't be easy to see, because we already have a 1px solid border that it butts directly against. Here's a screenshot using the patch from #8 (user-agent focus style) with Firefox 64 on Linux. Can you easily tell which has focus? The webkit style of a thick outline is easier to make out in this case.

Firefox screenshot, one summary has focus, but isn't very obvious.

re #13...

This issue should probably be reviewed by the UX team

What are we actually asking, then? This doesn't change any information architecture, meaning, or interactions. It's just a visual styling regression.

Adding the extra span tag would be permitted in a minor Drupal release but it feels like a hacky solution. Also, the Seven theme does not have a maintainer, so I am not sure who would make this decision.

It would come down to the front-end framework manager I suppose.

Finally, we need to consider that the community is actively working on new Administrative UI theme and the Seven theme is going to be deprecated and replaced.

We still don't know how long that will take though. My guess is at least 2 minor releases, if it the new theme follows the typical time for an experimental module to mature. So this is still worth addressing now - we can fix this in the next minor release, and it may qualify for a backport to the current minor release. The fact that we will ditch Seven eventually makes the extra span easier to swallow.

jrockowitz’s picture

I was thinking that the UX team could weigh in if it okay to use browser's default styling for the details summary. If we feel adding the <span> tag is an okay solution, then we don't really need to have any UX review.

jrockowitz’s picture

What is the span for in #10 - to make the selector more specific, or something else? I haven't been able to figure out the cause.

The issue that Chrome/Safari no longer support the underlining style for the <summary> tag but they do allow a <span> tag nested within the <summary> to be underlined.

I am tagging this 'Needs frontend framework manager review' so that we can get some initial input on is #10 an okay workaround, does this issue require a change record, and can the solution be back-ported to 8.6.x.

andrewmacpherson’s picture

It's bizarre, I can't figure out why this underline won't apply. I can't find any upstream bugs about it.

kristen pol’s picture

Thanks for the updates. If you need more testing, I'm happy to help out.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jrockowitz’s picture

I am at DrupalGovCon Contrib Sprint and teaching someone how to review a patch.

For now, we are going to use simplytest.me.

https://simplytest.me/project/drupal/8.8.x?patch[]=https://www.drupal.or...

jrockowitz’s picture

StatusFileSize
new1.06 KB

Here is a re-roll of the patch.

Here is the updated simplytest.me URL.

http://simplytest.me/project/drupal/8.8.x?patch[]=https://www.drupal.org...

dorianwinterfeld’s picture

StatusFileSize
new38.76 KB

screen shot of patch test

I have tested this patch in Chrome and verified that it works.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dww’s picture

Status: Needs review » Reviewed & tested by the community

I ran head-first into this mess over at #3102724-96: Improve usability of core compatibility ranges on available updates report. I discovered that the <details> on the /admin/modules page has no visual focus indication at all, searched for an existing bug report about that, and found this issue. I just uploaded a patch and a bunch of screenshots to #3102724 that seems to give a working cross-browser implementation of an underline (accomplished via a bottom-border, since text-decoration doesn't seem to work on <summary> on most browsers).

Now that I'm reading all this closely, I'm wishing I hadn't done all that. ;) The <span> inside the <summary> seems *way* better than the hacks I came up with.

I just tested this in combo with my prior patch in #3102724 and it's all working great, at least in Firefox, Chrome and Safari on a Mac.

Patch #22 in here is vastly simpler, easier to understand, and presumably much more reliable than the yucky alternatives I was fiddling with.

Bumping this to RTBC, in the hopes that @lauriii will sign-off on it ASAP and we can use this to solve the focus problems over at #3102724 (which is a critical task that's blocking a slew of other issues from being backported to 8.8.x and that will block the 9.0.0-beta1 release).

Thanks!
-Derek

bnjmnm’s picture

Just adding that I tested this in IE11 to confirm that the solution does not conflict with with the functionality in collapse.js for browsers that don't natively support details/summary -- everything worked fine.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs frontend framework manager review
+++ b/core/themes/seven/css/base/elements.css
@@ -161,9 +161,11 @@ details summary {
 details summary:focus {
-  text-decoration: underline;
...
+details summary:focus span {
+  text-decoration: underline;
+}

This will cause some problems with contrib compatibility because there are contrib projects that are manually creating details summary elements. As a result, focus effect wouldn't be available even on browsers that used to receive it before. This would also make the behavior inconsistent between details elements.

That said, it could be a bigger win to fix this accessibility issue in most instances of details. I would like the accessibility maintainers to weigh in on this.

I checked if all details summary elements in core receive span child element and it seems like we have to apply this change to views-view-table.html.twig as well.

rithesh bk’s picture

Assigned: Unassigned » rithesh bk
Issue tags: +VbContribution2020

currently working on this .....

rithesh bk’s picture

Assigned: rithesh bk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.02 KB
new363 bytes

Please find the updated file and interdiff file ...... . @lauriii changes has been done according to #27...

dww’s picture

Assigned: Unassigned » dww
Status: Needs review » Needs work

@Rithesh BK re: #29 -- sadly, no, that's not the requested change at all. @lauriii said:

it seems like we have to apply this change to views-view-table.html.twig as well.

I'll re-do this, since this issue is blocking #3102724: Improve usability of core compatibility ranges on available updates report which in turn blocks a bunch of other stuff, including all the next releases of core.

dww’s picture

Assigned: dww » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.64 KB
new4.45 KB

I believe like so?

@lauriii: Do we want any comments in core/themes/seven/templates/views-view-table.html.twig about why we're overriding it?

Do we need anything else here to get this done?

Thanks,
-Derek

dww’s picture

StatusFileSize
new5.65 KB
new345 bytes

To address the other concern in #27:

This will cause some problems with contrib compatibility because there are contrib projects that are manually creating details summary elements. As a result, focus effect wouldn't be available even on browsers that used to receive it before. This would also make the behavior inconsistent between details elements.

Couldn't we just do this? Leave text-decoration: underline on details summary:focus? I tried it on Chrome and Firefox and didn't spot any problems. I know it's technically a duplicate style for some browsers, but visually it works fine and that seems less disruptive than the alternative.

Thoughts?

Thanks!
-Derek

dww’s picture

StatusFileSize
new5.59 KB
new341 bytes

Sorry for the noise, but I slightly missed restoring the style, causing a bigger diff than needed. This is better.

The last submitted patch, 31: 2980304-31.patch, failed testing. View results

lauriii’s picture

Status: Needs review » Needs work
+++ b/core/themes/seven/css/base/elements.css
@@ -164,6 +164,9 @@ details summary:focus {
   text-decoration: underline;
...
+details summary:focus span {
+  text-decoration: underline;

This approach is great because this way we can ensure that this doesn't cause regressions with any markup 👍 Only downside of this is potential confusion when reading the CSS. This could be addressed with a comment explaining why we have "duplicated" this rule.

Let's also open a follow-up to explore if we could find a way to solve this which wouldn't require updating contrib markup.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new6.21 KB
new1.37 KB

Comments added.

I couldn't help myself and also added a note to the @file comment in core/themes/seven/templates/views-view-table.html.twig ;)

Follow-up: #3115222: Explore if underline focus style for details/summary can work without span

xjm’s picture

Issue tags: +Needs manual testing

FWIW I don't think this actually blocks #3102724: Improve usability of core compatibility ranges on available updates report, but based on @andrewmacpherson's description the issue is really serious so we should try to fix it regardless of what it's blocking.

We changed the browsers core supports in 8.8, so prior to commit, we should test the browsers in our hardcoded browserlist.

Furthermore, we should check whether Claro has any of the same bugs. Claro's focus styling is quite different so it may not be an issue; however, other theme bugs from Seven did end up in Claro. So would be good to know if Claro is affected prior to fixing Seven.

dww’s picture

Re: #37:

- Duly noted on not blocking #3102724
- Agreed on wider browser testing, I only looked at a couple.
- I can definitely confirm that Claro does not have this same bug. The bug is ultimately that not all browsers support text-decoration on details/summary elements. Claro's focus styles for details/summary are entirely different, so the lack of consistent support for text-decoration doesn't matter to Claro.

Cheers,
-Derek

dww’s picture

Re: #27:

I checked if all details summary elements in core receive span child element and it seems like we have to apply this change to views-view-table.html.twig as well.

The #type => 'details' render element does more than spit out <details><summary>. Apparently IE11 doesn't support <details> properly (https://www.caniuse.com/#feat=details), so there's a JS polyfill that gets injected. Also some aria-related stuff. So doing this directly in the template means we lose all this goodness, and either this <details> from the views template will not work and be accessible on some browsers, or we have to duplicate all the stuff the render element does for us.

Quoting from andrewmacpherson in Slack:

So long as <details> is being added via Render Element API, then our polyfills get added automatically.

All this makes me wonder if views-view-table.html.twig should be trying to inject <details> directly at all. This is almost certainly out of scope here, but it seems we're making that worse by the changes I made in #31 and later to address @lauriii's concerns.

Should we:

A) Open a follow-up to change how views-view-table.html.twig handles the details so it's done via render element instead of directly in the template?

B) Open a follow-up to change views-view-table.html.twig so that it duplicates all the effort from the render element re: polyfills + Aria?

C) Re-scope this issue to handle all of the above?

D) Other?

Thanks,
-Derek

lauriii’s picture

I would open a follow-up to discuss how to handle the polyfill issue with Views. It's also not a problem specific to Views since there are some other places as well where details instance are being initialized manually http://grep.xnddx.ru/search?text=%3Cdetails&filename= .

What I don't fully understand is how does this change cause a regression in the Views template, but not in the details template?

dww’s picture

Issue tags: +Needs followup

Re: follow-up: 👍 tagging for now, I'll open it later (about to go to sleep).

Re: "how does this change cause a regression in the Views template, but not in the details template?"

Sorry, I don't think I was clear. "This change" is adding <span> to the details template. There's no regression. It just helps the details template have a working focus style.

What I meant is that the act of working on #31 made me realize that the views template, which handles <details> directly, not via a render array, means the views template is already *not* getting the polyfills and therefore not consistently working on all browsers. Adding the <span> to the views template doesn't "cause a regression" -- it fixes the focus styles. But it made me realize we already have another bug, which is that we're missing the polyfills anywhere we're using <details> without using a render array.

We're not actually making anything "worse". I meant that to get the views template into shape (with a working focus style), we're manually adding a <span>. But maybe we should be converting it to use a render array for that <details>, which would then give us the <span> for free, plus get the polyfills injected properly.

Hope that all makes sense. Sorry for not being more precise in the first place.

Thanks,
-Derek

dww’s picture

dww’s picture

StatusFileSize
new1.39 KB
new4.66 KB

Optimistically assuming #3119279: views-view-table.html.twig template directly uses details without render array and polyfills lands soon, we don't need any of the bloat/complication from #31 and this should be all we need to fix this bug.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dan2k3k4’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @dww

Patch looks good to me, and follow-up issue #3119279 is already RTBC.

  • lauriii committed 4569c10 on 9.1.x
    Issue #2980304 by dww, jrockowitz, Rithesh BK, Kristen Pol,...

  • lauriii committed c2335ab on 9.0.x
    Issue #2980304 by dww, jrockowitz, Rithesh BK, Kristen Pol,...

  • lauriii committed fd5efa4 on 8.9.x
    Issue #2980304 by dww, jrockowitz, Rithesh BK, Kristen Pol,...
lauriii’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs manual testing
StatusFileSize
new641 bytes

I didn't expect any browser incompatibilities with this but tested this with latest versions of Chrome, Firefox, IE 11, Edge, Safari and Opera and the underline was visible consistently on all browsers. 🙌

I adjusted the code style on the template, interdiff attached.

Committed 4569c10 and pushed to 9.1.x, 9.0.x and 8.9.x because this seems like a low risk issue that fixes a major accessibility issue. Thanks!

andrewmacpherson’s picture

Thanks for working on this everyone. It's been fiddly to diagnose and test everything.

abaier’s picture

Maybe I found a regession regarding this issue for the field_group module. Using Seven, the horizontal tabs feature does not render the tab titles anymore, probably because the selector does not apply anymore.

See: https://www.drupal.org/project/field_group/issues/3104205#comment-13607521

Does field_group have to adapt to the additional <span> or does this belong here?

Thanks in advance, Anton

Status: Fixed » Closed (fixed)

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