Open dav-idc opened 11 months ago
These are some of the main scenarios where I've bumped into this as a potential last-ditch plan to meet the AAA level of 'Focus not obscured'.
As with the 'problem' section above, the use cases occur when the following is true:
A 'quick escape' or 'exit this page' safety feature floats over top of sidebar navigation content on a mobile desktop.
The example image for 'case 1' is taken from a modified version of this GOV.UK Frontend review app page for the 'exit this page' component:
Image description: Screenshot of a GOV.UK Frontend sample 'review' page with a red rectangular 'exit this page' component on the right-hand side of the page. The 'exit this page' element floats above some sidebar content, including a paragraph with a link. It partially obscures the link which says 'Lorem dolor ipsum'. No element in the image is currently receiving keyboard focus.
A persistent chatbot window covers up a large amount of body content, including several focusable elements.
The example image for 'case 2' is taken from an unmodified version of this Cardiff Council chatbot informational page.
Image description: Screenshot of a Cardiff Council page with the 'BOBi' chatbot pop-over window expanded. The pop-over partially and fully obscures clickable social media icons, footer links, and an in-paragraph privacy link. The privacy link is currently focused, but only the top half of its red focus outline is currently visible.
A persistent cookie consent banner pops over a large percentage of main page content, partially or fully obscuring several links.
The example image for 'case 3' is taken from an unmodified version of this McDonald's UK homepage.
Image description: Screenshot of the McDonald's UK homepage, before the cookie consent banner is dealt with. The consent pop-over fully obscures the width of the 1st leftmost column of page content, including images, paragraphs and a series of links. One link, "medium salad", is currently focused with a blue focus outline, but the bottom half of the link and focus outline are obscured.
I'm proposing a potentially unpopular CSS technique to meet the AAA level criterion, '2.4.12 Focus not Obscured (Enhanced)'.
As of the creation of this GitHub issue, there are no techniques exclusive to the AAA level of 'Focus not obscured'. The one technique offered, technique C43, is also applied to the AA level.
The problem
The AAA level criterion for 'Focus not obscured' has a very high standard for success:
This creates a difficult scenario, which doesn't yet appear to have a sufficient technique to solve it. There's a chance to fail 2.4.12 any time that all the following are true:
When these 3 things are true, there's a chance that focused 'body content' elements become obscured by the pop-over element.
The solution
Basically: on focus, set the z-index really high for 'body content' elements in the given area.
This is a potentially controversial solution, but I believe it's worth considering due to the current absence of any alternative AAA-level 'focus not obscured' techniques.
Example CSS
Pros and cons
This works because:
This might be controversial because:
Additional details
This solution requires all focusable elements which might be obscured by the pop-over element to have:
position: relative
orposition: absolute
background: white
)It also requires careful selection of a z-index value. I tried various index amounts, to try and find a universally high enough value to override pop-over elements like chatbots, cookie banners, menus, etc. The only one that is guaranteed to work is pretty much just infinity. It seems ridiculous, but
calc(infinity)
might be appropriate to guarantee focus is never obscured.Why is this only for the 'enhanced' level?
I believe this technique should be exclusive to the 'enhanced' level, because it specifically solves the problem of making sure no part of a focused element is obscured. This technique isn't really needed to meet the 'minimum' criterion, and would be a bit overkill for that level. There are other techniques, including the existing
scroll-margin
technique, that already work well for the AA 'minimum' criterion for 'focus not obscured'.