question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Focus ring via :focus-visible

See original GitHub issue

Description

It may be desirable to remove the default focus ring which appears on mouse click. For <model-viewer> to be accessible and compliant there must be a focus ring visible when keyboard users interact with the model. This is a requirement from WCAG 2.4.7 Focus Visible.

A possible work-around would be to implement the :focus-visible polyfill which, I assume, would be encapsulated within <model-viewer>. With this in place, we’d be free to remove the outline for mouse/touch, and display the outline for keyboard only.

/*
  Provide basic, default focus styles.
*/
canvas:focus {
  …
}

/*
  Remove default focus styles for mouse users ONLY if
  :focus-visible is supported on this platform.
*/
canvas:focus:not(:focus-visible) {
  …
}

/*
  Optionally: If :focus-visible is supported on this
  platform, provide enhanced focus styles for keyboard
  focus.
*/
canvas:focus-visible {
  …
}

Screen Shot 2019-04-02 at 9 44 31 AM

Live Demo

Browser Affected

  • Chrome
  • Edge
  • Firefox
  • Helios
  • IE
  • Safari

OS

  • Android
  • iOS
  • Linux
  • MacOS
  • Windows

Versions

  • model-viewer: v0.1.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
cdatacommented, May 15, 2019

https://github.com/WICG/focus-visible/pull/196 as been approved, so we should be able to move forward with a aspirational integration.

1reaction
cdatacommented, May 2, 2019

I have opened https://github.com/WICG/focus-visible/pull/196 to add Shadow DOM support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

focus-visible - CSS: Cascading Style Sheets - MDN Web Docs
The :focus-visible pseudo-class applies while an element matches the :focus pseudo-class and the UA (User Agent) determines via heuristics ...
Read more >
:focus-visible CSS pseudo-class | Can I use... Support ...
The :focus-visible pseudo-class applies while an element matches the :focus ... should be specially indicated on the element (typically via a “focus ring”)....
Read more >
:focus-visible in WebKit - May 2021 - Rego's Everyday Life
These elements have always matched (and still match) :focus by default, and have usually showed a focus ring when focused via mouse click....
Read more >
The :focus-visible Trick | CSS-Tricks
This prevents the focus ring from appearing on mousedown on desktop or touch on mobile… If you want a custom style when the...
Read more >
Focus Visible - Understanding Success Criterion 2.4.7
2.4.7 Focus Visible: Any keyboard operable user interface has a mode of operation where the keyboard focus indicator is visible. (Level AA) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found