Skip to content

[Discuss] Cross-browser focus states for overflow containers #3385

Closed

Description

@snide

We had some discussion on the resizable container scroll interactions as part of #2701 (comment), specifically around the following two issues. It was decided this is a more global issue than one component and we should think holistically at the problem.

  • Should EUI give guidance and adhere to applying tabindex=0 for any elements with an applied overflow: auto property.
  • How should EUI consistently apply styling for such a cases? How can we make this not weird specifically in auto situations where the element may or may not be scrollable.

Currently the browsers treat scrollable containers differently and there is some suggestive guidance from AXE to correct it. https://dequeuniversity.com/rules/axe/3.5/scrollable-region-focusable?application=AxeChrome

Likely if applied, even in EUI components, there would still need to exist guidance of some sort, since EUI would not be able to control all general downstream usages, where tabindex would need to be applied manually. Potentially we could mitigate this by introducing a small component called EuiScrollableContainer that could act as a simple utility component to apply tabindex and the proper styling selectors necessary to attack this consistently.

Activity

  1. added
    design decision
    on Apr 24, 2020
  2. changed the title [-][Discuss] Focus state for resizable containers cross-browser[/-] [+][Discuss] Cross-browser focus states for overflow containers[/+] on Apr 24, 2020
  3. myasonik commented on Apr 24, 2020

    @myasonik
    Contributor

    Would be a nice enhancement to only apply tabindex=0 if the content is actually scrollable, not just if it could be scrollable

  4. myasonik commented on Jan 29, 2021

    @myasonik
    Contributor

    Related Kibana issue: elastic/kibana#89490

    Edit: Sorry about the miss click and the extra pings!

  5. cchaos commented on Mar 19, 2021

    @cchaos
    Contributor

    A couple thoughts I've had on this recently, as it has also come into question via Cloud, and some notes for my future self.

    In a recent update (in master only as of today) to the docs, I've included messaging on our CSS utilities page in the overflow section basically giving consumers an indication that when using these utilities, to better support a11y, they also need to add tabIndex to the container.

    Screen Shot 2021-03-19 at 15 45 46 PM

    But, I also updated those overflow utilities to hide the focus rings from non-keyboard users with simply the :focus { outline none } style, which gets overridden for keyboard users in browsers that support :focus-visible.

    There's still more to do for this though:

    • Audit EUI specific components to update their styles to be the same or use the utility
    • Safari still behaves differently from Chrome and Firefox and needs to be addressed

    As an aside about :focus-visible and Safari, and my future self note, what I can gather from how Safari behaves is that it respects :focus and ignores :focus-visible. So in the above scenario, Safari will never show a focus ring. But with all other interactable, and by default, content we reverse this scenario and ensure everything that gets :focus gets a ring, but only if they support :focus-visible does it hide for mouse users.

    What we probably want is some better helper for exactly these 2 scenarios.

    1. This is directly interactable content, like a <button> and should always show a focus ring, unless the browser can support :focus-visible or (with the new CSS in JS theming) is forced by the user's preference.
    2. This is indirectly interactable content, like an overflowing <div> which doesn't need a visible ring, but must be able to receive keyboard focus. Therefore, remove the focus ring unless the browser can support :focus-visible or (with the new CSS in JS theming) is forced by the user's preference.
  6. github-actions commented on Sep 16, 2021

    @github-actions

    👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

  7. added
    stale-issue
    on Sep 16, 2021
  8. removed
    stale-issue
    on Sep 17, 2021
  9. github-actions commented on Mar 17, 2022

    @github-actions

    👋 Hey there. This issue hasn't had any activity for 180 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

  10. added
    stale-issue
    on Mar 17, 2022
  11. cchaos commented on Mar 17, 2022

    @cchaos
    Contributor

    I'm keeping this in the backpocket of the Emotion conversion to evaluate per-component.

  12. added and removed
    stale-issue
    on Mar 17, 2022
  13. 1Copenut commented on Apr 3, 2023

    @1Copenut
    Contributor

    I took a look at this today, and determined we have language in the EUI design system about making scrollable content keyboard focusable:

    However, guidance alone leaves responsibility in the hands of consumers to apply a tabindex="0" to relevant containers. We could build out a simple component that checks for Element.scrollHeight being larger than Element.clientHeight and applies a state or prop to include tabindex. But there again, we're asking consumers to remember to use this new element.

  14. 1Copenut commented on Apr 3, 2023

    @1Copenut
    Contributor

    Additionally, some of our examples on the Scroll utility docs page do not have a visible focus halo. This doesn't pass muster for WCAG SC 2.4.7 Focus Visible. Whatever we decide to do, these examples will need to have the CSS updated to not suppress the outline.

  15. added
    answered
    on Apr 4, 2023
  16. github-actions commented on Apr 8, 2023

    @github-actions

    👋 This issue hasn't seen activity in 3 days, so we're automatically closing this issue as answered. Please leave a comment if that's not the case, or if you have any remaining questions or issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

accessibilityanswereddesign decision

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions