Skip to content

Commit 8513d25

Browse files
authored
fix: o-overlay, which to a h2 header (#1291)
Typically one h1 on a page helps create a navigatable structure. There Is No Document Outline Algorithm. https://adrianroselli.com/2016/08/there-is-no-document-outline-algorithm.html#Update10 But I wasn't sure what the right answer is now we have `aria-modal` that can trap focus and mark other elements as inert, and went on a little side quest. Turns out W3C's APG Task Force (ARIA Authoring Practices Guide) discussed this in a meeting a few years ago. w3c/aria-practices#551 (comment) They concluded: - It is helpful if there is a consistent approach across dialogs in an application. - There is not necessarily a need for the APG to prescribe a specific approach. So, I guess provided you're in a modal either h1 or h2 is fine. APG continue to use h2 in their example and Material UI are undecided, with some interesting back and fourth on when a h1 or h2 might be a better experience. mui/material-ui#34250 Probably, it's not a big deal either way. If I had to pick a global rule based on the above and no access to direct user testing for this, I'd go with h2. Here it is. A quick PR to switch to a h2. This was prompted by a user question in the support Slack channel. https://financialtimes.slack.com/archives/C02FU5ARJ/p1696242420071219
1 parent 745e439 commit 8513d25

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

components/o-overlay/src/js/overlay.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ class Overlay {
302302
heading.appendChild(button);
303303
}
304304

305-
const title = document.createElement('span');
306-
title.setAttribute('role', 'heading');
307-
title.setAttribute('aria-level', '1');
305+
const title = document.createElement('h2');
308306
title.className = 'o-overlay__title';
309307
title.innerHTML = this.opts.heading.title;
310308
title.setAttribute('id', headingId);

components/o-overlay/src/scss/_mixins.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@
2929
opacity: 1;
3030
transition: opacity 0.3s ease-in-out;
3131
}
32+
.o-overlay__heading,
33+
.o-overlay__title {
34+
@include oTypographySans($scale: 2, $weight: 'regular');
35+
}
36+
3237
.o-overlay__heading {
33-
@include oTypographySans($scale: 2, $include-font-family: false);
3438
margin: 0;
3539
overflow: hidden;
3640
background: _oOverlayGet('heading-background');

0 commit comments

Comments
 (0)