diff --git a/app/assets/javascripts/base.js.erb b/app/assets/javascripts/base.js.erb index 3ed88a2e9..266950ebe 100644 --- a/app/assets/javascripts/base.js.erb +++ b/app/assets/javascripts/base.js.erb @@ -123,6 +123,10 @@ var instantClick prog.classList.remove("showing"); if (newUrl) { + const skipLink = document.querySelector('.skip-content-link'); + if (skipLink) { + skipLink.focus(); + } history.pushState(null, null, newUrl.replace("?samepage=true","").replace("&samepage=true","")) var hashIndex = newUrl.indexOf('#'), diff --git a/app/assets/stylesheets/components/header.scss b/app/assets/stylesheets/components/header.scss index abcf929b4..2d907a140 100644 --- a/app/assets/stylesheets/components/header.scss +++ b/app/assets/stylesheets/components/header.scss @@ -134,14 +134,17 @@ height: var(--header-height); transform: translate(-50%, -200%); transition: transform var(--transition-props); +} - &:focus, - &:focus-within { - pointer-events: auto; - transform: translate(-50%, 0); - outline: none; - border: 2px solid var(--header-button-focus-color); - } +.js-focus-visible .skip-content-link:focus:not(.focus-visible) { + visibility: hidden; +} + +.js-focus-visible .skip-content-link:focus { + pointer-events: auto; + transform: translate(-50%, 0); + outline: none; + border: 2px solid var(--header-button-focus-color); } .pwa-nav-buttons {