vaadin / web-components

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
https://vaadin.com/docs/latest/components
470 stars 83 forks source link

[confirm-dialog] Minor accessibility enhancements #467

Open anezthes opened 3 years ago

anezthes commented 3 years ago

Heading

Accessibility guidelines recommend using headings in order: <h1>, <h2>, <h3>, etc. Each page should have an <h1>, describing the main purpose of the page (similarly to a page title), and it's recommended to only use one per page.

Confirm Dialog uses <h3> for its title, implying the dialog is a subsection of <h2> from a content hierarchy/document outline point-of-view. If we need a default/hard-coded heading, I'd argue <h2> is the safer/expected option.

aria-labelledby & aria-describedby

When a title is present, is should be given an id and used as a label for the dialog (via aria-labelledby). Similarly, Confirm Dialogs featuring support text would benefit from setting the aria-describedby attribute to the id of the element used for displaying the text.

Related: https://github.com/vaadin/vaadin-dialog/issues/227

Header & footer

We could/should also consider using <header> and <footer> tags to improve accessibility and to give the structure some more semantic meaning.

Examples:

knoobie commented 3 years ago

I would argue against a forced <h2> or <h3> this creates problems for the developer, because you are forcing a hierarchy. Vaadin doesn't know in which depth the dialog is or should be.

Typically a web application is like this:

Another example:

Instead of the forced hierarchy, I would recommend to use <header> combined with either no <h*> or allowing the developer to change it.

web-padawan commented 2 years ago

We have added header & footer to vaadin-dialog and they use <header> and <footer> HTML tags:

https://github.com/vaadin/web-components/blob/5d0cdee069f866037c507265fafb4d0476795333/packages/dialog/src/vaadin-dialog.js#L18-L21

https://github.com/vaadin/web-components/blob/5d0cdee069f866037c507265fafb4d0476795333/packages/dialog/src/vaadin-dialog.js#L27-L31

So this issue should be eventually about updating vaadin-confirm-dialog to use these elements.