Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login: incorrect heading levels #98

Open
TetraLogicalHelpdesk opened this issue Mar 17, 2021 · 6 comments · May be fixed by #8445
Open

login: incorrect heading levels #98

TetraLogicalHelpdesk opened this issue Mar 17, 2021 · 6 comments · May be fixed by #8445
Assignees
Labels
a11y Accessibility issue enhancement New feature or request vaadin-login

Comments

@TetraLogicalHelpdesk
Copy link

WCAG Level

Level A

Priority

Medium

Pages/screens/components affected

Description

When content is presented in a way that implies it has a particular structure, like headings that break up sections of content, but the same structure is not there in the HTML, it makes it difficult for anyone who cannot see the intended structure to navigate and understand it. Headings should have levels that represent their place within the hierarchy without skipping levels.

While the heading levels for some variations of the Login component are correct, for others they are either incorrect or lack the ability to be configured when placed into the context of a page.

User impact

Screen readers depend on HTML for information about the structure of content. Working in conjunction with the browser the screen reader takes information from the HTML and uses it to convey the structure/relationships to users. When HTML markup is used inappropriately, screen readers give users the wrong information about the content or the structure of the document.

Required solution

Ensure that headings are used in such a way as to represent the hierarchy of content within the document.

Implementation guidance

The Login form has several variations, but they all have the same basic heading structure.

  • The title, when provided, is an <h1>
  • The form heading ("Log in" by default), is an <h2>
  • The error messages heading, that appears after the form heading, is an <h5>

This can be seen in the Validation example:

The validation example with title heading of "App name", form heading of "Log in", and error message heading of "Incorrect username or password"

In most cases, the Login component is likely to be used on a page of its own or as a modal dialog. In these circumstances heading levels of 1 and 2 for the component title and the form heading respectively are appropriate. However, in any other circumstance, for example including the login form within a page's sidebar, these heading levels are unlikely to be appropriate. The example page is a case in point: each version of the Login component follows either the <h1> of the page or an <h2> for the sub-sections.

Additionally, the heading for the error messages, and <h5> following and <h2> by default, is always incorrect and should be an <h3> in that context.

Ideally it should be possible to configure the initial heading level from which other headings within the component are derived. The level of the form heading will vary depending on whether there is a separate title provided for the component.

Alternatively, the heading level for the error message should be corrected and the component recommended for use only when it is the main content of a page if the component has a title, or content that is one level below the page's main heading (to account for the form heading's <h2>) when the component does not have a title.

Test procedure(s)

Use these steps to confirm that the solution has been correctly applied to issues identified within the test sample, and to test the rest of the website for instances of the same issue:

  1. Identify headings within the component
  2. Make sure each heading has a heading role and a level that represents its place in the document hierarchy

Definition of done

Complete all of these tasks before closing this issue or indicating it is ready for retest:

  • All issues identified within the test sample have been resolved.
  • The rest of the components, their variants, and the documentation website have been tested for the same issue.
  • All issues identified throughout the rest of the components/website have been resolved or filed as new issues.

Related standards

More information

Test data

Test date: March 2021
Website: vaadin.com/components, vaadin.com/docs-beta

@web-padawan web-padawan added the a11y Accessibility issue label Mar 17, 2021
@rolfsmeds
Copy link
Contributor

rolfsmeds commented Dec 30, 2021

  1. Replace the <h5> used in the error message with <strong>
  2. Replace <h2> with role="heading" and provide API for setting the heading-level. This should be done in the same way for details: heading level cannot be specified for elements with heading role #90.

@rolfsmeds rolfsmeds added enhancement New feature or request vaadin-login labels Dec 30, 2021
@knoobie
Copy link
Contributor

knoobie commented Dec 30, 2021

@rolfsmeds The same about 2. probably applies to the confirm dialog as well.

const h3 = document.createElement('h3');

@knoobie
Copy link
Contributor

knoobie commented Jan 16, 2022

Just thinking out load: Should lumo be updated that a h3 and aria-level=3 element get the same styling?

@rolfsmeds
Copy link
Contributor

Good question. I guess the only alternative is to apply the appropriate styles to these embedded headings separately, but that seems a bit... dirty, and un-design-system-like. Thoughts, @jouni ?

@jouni
Copy link
Member

jouni commented Feb 23, 2022

This sounds like a case for utility classes, or the “text component” we’ve been talking about. I mean, targeting aria-level=3 or .h3 (in addition to h3) doesn't sound too different to me.

At the moment we happen to have the h3 defined in typography.js and color.js, and the other in utilities/typography.js (spread across .text-xl, .font-semibold, and .text-header). Would be great to have them defined in just one place.

The “text component” could perhaps be more convenient to use, but I’m not sure.

I’m not sure what the best way forward is, thinking long-term.

@rolfsmeds
Copy link
Contributor

To do:

  • Replace the <h5> markup of the error box with <strong>
    • (Consider marking the error box as role="alert")
  • Make the "Log in" <h2> level dynamic based on whether the title is displayed (so that it's rendered as <h1> if no title is provided)
  • Introduce an API for setting the root heading level, which then affects both the Title (if provided) and the "Log in" heading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Accessibility issue enhancement New feature or request vaadin-login
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants