Skip to content

Fix accessibility of toolbar toggler #37739

Closed
@Chi-teck

Description

@Chi-teck

Symfony version affected: master

Description
Here is the currently used markup of "Show toolbar" link.

<a href="#" title="Show Symfony toolbar" tabindex="-1" id="sfToolbarMiniToggler-95d68f" accesskey="D">
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
        <!-- SVG image -->
    </svg>
</a>

I think it has a few semantic and accessibility issues.

  1. First of all, using <a href="#"/> here is not semantically correct, because it is not a link but button. It needs to be rendered with <button/> tag or at least have role="button".
  2. tabindex=-1. Why? It makes the toggler not reachable through keyboard. Note that accesskey cannot be considered as a replacement for tabindex because it may conflict with a system or browser keyboard shortcut. That's what is happening on my local machine. See accessibility concerns.
  3. aria-expanded attribute is missing. Also we may consider adding aria-controls and aria-haspopup attributes.
  4. SVG images need aria-hidden=true and focusable=false attributes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions