Skip to content

Commit

Permalink
fix(a11y): prevent accessing page without h1 (#2497)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionelB authored Mar 18, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7750969 commit 02a06a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/code-du-travail-frontend/src/a11y.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,10 @@ export function A11y({ initialTitle = "" }) {
* the aria-live annouvement.
*/
setTimeout(() => {
setAriaTitle(`${document.querySelector("h1").textContent}`);
const titleNode = document.querySelector("h1");
if (titleNode) {
setAriaTitle(`${titleNode.textContent}`);
}
const focusRoot = document.querySelector("[data-next-focus-root]");
if (focusRoot) {
focusRoot.focus();

0 comments on commit 02a06a4

Please sign in to comment.