Skip to content

Commit

Permalink
feature: adds skip to content button
Browse files Browse the repository at this point in the history
  • Loading branch information
GentlemanHal committed Apr 23, 2024
1 parent 1bdd0fd commit 1a8017c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.15.4
7.16.0
8 changes: 8 additions & 0 deletions src/client/Nevergreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,11 @@ it('should show menus when any key is pressed, allowing the user to navigate to

expect(showMenus).toHaveBeenCalledTimes(2)
})

it('should have a skip to content button', async () => {
render(<Nevergreen />)
await waitForLoadingToFinish()
expect(
screen.getByRole('button', { name: 'Skip to content' }),
).toBeInTheDocument()
})
9 changes: 9 additions & 0 deletions src/client/Nevergreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { useNavigationShortcuts } from './NavigationShortcutsHook'
import { Outlet, useOutletContext } from 'react-router-dom'
import { useAppSelector } from './configuration/Hooks'
import styles from './nevergreen.scss'
import { PrimaryButton } from './common/forms/Button'

interface AppState {
readonly menusHidden: boolean
Expand Down Expand Up @@ -75,6 +76,14 @@ export function Nevergreen(): ReactElement {
onKeyDown={showMenus}
{...showMenusOn}
>
<PrimaryButton
onClick={() => {
document.getElementsByTagName('h1').item(0)?.focus()
}}
className={styles.skipButton}
>
Skip to content
</PrimaryButton>
<Header hide={menusHidden} />
<Banner
message={bannerMessage}
Expand Down
12 changes: 12 additions & 0 deletions src/client/nevergreen.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use 'common/colours';
@use 'common/accessibility';
@import 'defaults';

.nevergreen {
Expand All @@ -11,6 +12,17 @@
}
}

.skipButton {
&:not(:focus) {
@include accessibility.visually-hidden;
}

&:enabled:focus {
margin: 0;
position: absolute;
}
}

.main {
background-color: colours.$black;
display: flex;
Expand Down

0 comments on commit 1a8017c

Please sign in to comment.