From 6d7e92d73b2bb24a584c0f0875fd03d8fd1aa7d0 Mon Sep 17 00:00:00 2001 From: btzr-io Date: Wed, 14 Jul 2021 22:08:30 -0500 Subject: [PATCH] improve header accessibility add skip navigation link + minor fixes --- static/app-strings.json | 1 + ui/component/header/view.jsx | 21 +++++++++++++++++++++ ui/component/page/view.jsx | 1 + ui/component/sideNavigation/view.jsx | 1 + ui/scss/component/_header.scss | 18 ++++++++++++++++++ 5 files changed, 42 insertions(+) diff --git a/static/app-strings.json b/static/app-strings.json index db3a632c5..524f02dfc 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2055,5 +2055,6 @@ "added to": "added to", "removed from": "removed from", "Item removed from Watch Later": "Item removed from Watch Later", + "Skip navigation": "Skip navigation", "--end--": "--end--" } diff --git a/ui/component/header/view.jsx b/ui/component/header/view.jsx index 8d127823a..2d03a19dd 100644 --- a/ui/component/header/view.jsx +++ b/ui/component/header/view.jsx @@ -64,6 +64,24 @@ type Props = { activeChannelStakedLevel: number, }; +const SkipNavigationButton = () => { + const skipNavigation = (e) => { + // Match any focusable element + const focusableElementQuery = ` + #main-content [tabindex]:not([tabindex="-1"]):not(:disabled), + #main-content a:not([aria-hidden]):not([tabindex="-1"]):not(:disabled), + #main-content button:not([aria-hidden]):not([tabindex="-1"]):not(:disabled) + `; + // Find first focusable element + const element = document.querySelector(focusableElementQuery); + // Trigger focus to skip navigation + if (element && element.focus) { + element.focus(); + } + }; + return