Re: Best approach for meeting Success Criterion 1.4.13 Content on Hover or Focus via ESC key

That script relates to Heydon’s toggletip,  not the tooltip -  i.e. one that is triggered not by focusing/hovering, but by activation. Still not sure whether it therefore can apply in quite the same way to true hover/focus content. Maybe needs experimentation. I have not yet come across any (CSS-generated) hover/focus content that can be dismissed by ESC - but to be honest, I have probably never tried. I wonder whether the reason for the dearth of implementations is that no one has ever understood or payed attention to the use case. It may also be difficult to implement? For example, if hover cursor is still above the trigger and you dismiss the popup that hovering causes by ESC, would you not need to change the a:hover / a:focus CSS statement or witness that the content pop up again immediately?

I wonder whether this has been thought through right to the end.

Detlev

> Am 24.08.2018 um 12:10 schrieb Alastair Campbell <acampbell@nomensa.com>:
> 
> Hi Detlev,
>  
> > I am just wondering what the most elegant way would be to implement closing via pressing ESC to close whatever popup menu or custom tool tip happens to be open on a page
>  
> A good resource for this type of thing is Heydon’s inclusive design components, e.g:
> https://inclusive-components.design/tooltips-toggletips/ <https://inclusive-components.design/tooltips-toggletips/>
>  
> Includes:
> // Remove toggletip on ESC
>     toggletip.addEventListener('keydown', function(e) {
>       if ((e.keyCode || e.which) === 27)
>       liveRegion.innerHTML = '';
>     });
>  
> The code within the if-statement will depend on how the pop-over was instantiated in the first place, but you get the idea.
>  
> I *think* that if you’ve registered that type of event on an element, even if you have more than one open, pressing esc will close every instance which has that event registered.
>  
> However, worth a test or discussion with a JS expert.
>  
> Cheers,
>  
> -Alastair

Received on Saturday, 25 August 2018 09:26:25 UTC