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.
I was just forwarded this article - http://hugogiraudel.com/2016/10/13/css-hide-and-seek/
I haven't tested this, but essentially she's recommending:
.visually-hidden {
border: 0 !important;
clip: rect(1px, 1px, 1px, 1px) !important;
clip-path: inset(50%) !important;
height: 1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
white-space: nowrap !important;
}
.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
clip-path: none !important;
height: auto !important;
overflow: visible !important;
position: static !important;
width: auto !important;
white-space: normal !important;
}
We'd need to keep clip
(even though it is depreciated) and add clip-path
as the latter's support isn't all that great thus far.
Would love feedback on this.
Comment | File | Size | Author |
---|---|---|---|
#8 | CSS-Clip-Deprecated-2819823.patch | 2.47 KB | mgifford |
Comments
Comment #2
mgiffordComment #3
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedAdding related issue; #2464595: Elements that use .visually-hidden and .focusable aren’t read when using VoiceOver in iOS or in Chrome also has a patch which changes the clip property for .visually-hidden.
Comment #4
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedThis would be a good one to review at the upcoming Global Sprint Weekend.
Comment #5
mgiffordComment #7
left CreditAttribution: left commentedHello,
I did some testing in Ubuntu Chrome Version 56.0.2924.76 (64-bit) and Firefox 51.0.1 (64-bit) on the 'Skip to main content' anchor element.
From Can I Use http://caniuse.com/#feat=css-clip-path, I understand I shouldn't need the -webkit- prefix for the clip-path property in my version of Chrome.
However, when I use @mgifford's CSS rules from the original post, the 'Skip to main content' anchor element does not display visually when in focus. It is however still read out by ChromeVox.
If I refer to the article @mgifford linked to (http://hugogiraudel.com/2016/10/13/css-hide-and-seek/) and use its recommended CSS, we get:
I think this works as intended, but second opinions would be good :)
Comment #8
mgiffordThanks for testing this @left. I've rolled it up here. Would be good to test the patch again (and with Windows and Mac). Thanks for testing this in Ubuntu.
Comment #9
afoster CreditAttribution: afoster commentedTested on Mac 10.11 and it worked fine in with voice over in Chrome 55.0.2883.95 and Safari 10.0.2, and firefox 50.0.1
Comment #10
mgiffordI'd like this to get tested in Windows too. Thanks for testing this @afoster
Comment #11
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented@left Thanks for working on this during the sprint weekend.
Comment #12
develdru CreditAttribution: develdru as a volunteer and at OpenSense Labs commented@mgifford I tested on Windows 10 and found following result:
Thanks
Comment #13
develdru CreditAttribution: develdru as a volunteer and at OpenSense Labs commentedComment #14
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commented@left Thanks for reviewing the suggested changes.
@develdru - Thanks for these additional testing results.
I'm not sure if we should go ahead and commit this in a hurry, or if it's worth checking for other suggestions among wider front-end/accessibility community. My own view is that I haven't encountered any visually-hidden text in Drupal where we'd consider it broken. So to me this sounds more like a modernization plan than a urgent bug-fix.
@mgifford What do you think? Is it urgent?
Note that this patch still includes the deprecated
clip
but keeps it before the newclip-path
. The CSS nuances are beyond me, I'm afraid.I think it's worth considering this article too: Beware smushed off-screen accessible text. The issue there is that some screen reader speech doesn't have the right pauses. It would be good to look for any examples of this among Drupal's many hidden titles, and whether this patch is makes any difference. The patch in #8 includes the suggested
white-space: no-wrap
. Before reading that article, I would have put it down as a speech-synthesis quirk that is beyond our control. It's good to know that we might be able to improve it.Comment #15
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedMaybe let's say this is a target for 8.4.x, which gives us time to play with it.
Comment #16
mgiffordAs far as I know it isn't urgent. I think browsers will support clip for a bit. Just something to fix going ahead.
Comment #17
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedLet's see if the major browsers have indicated when they expect to remove CSS clip support.
Comment #19
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedThere's a brand new issue about visuallyhidden class in the HTML5 Boilerplate repo. It's another approach to compare ours against.
macOS - VoiceOver / Chrome announcing visually hidden text out of order
Comment #20
mgiffordComment #23
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedchanging issue tag to a more accurate name, got some others with this tag already
Comment #33
mgiffordSeems like there is still partial support across the board https://caniuse.com/css-clip-path
From HTML5 Boilerplate
https://github.com/h5bp/main.css/blob/main/src/_helpers.css
Comment #34
mgiffordAdding another example from the community - https://blog.logrocket.com/design-accessibility-css-visually-hidden-class/
Still no need to update as long as browser support clip[] at this point.