Skip to content

Commit

Permalink
fix: a11y: move skip link anchor entry point to unique page content i…
Browse files Browse the repository at this point in the history
…n default layout (#1212)

* adjusts default layout file to put the is of main content onto the page content instead of the main element

* update unit test

---------

Co-authored-by: Abigail Young <abbyoung@gmail.com>
  • Loading branch information
shkeating and abbyoung authored Feb 22, 2024
1 parent 4f34bc4 commit c2e8e8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/layout/DefaultLayout/DefaultLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ describe('DefaultLayout component options', () => {
})

describe('DefaultLayout component', () => {
let container: HTMLElement
beforeEach(async () => {
renderWithAuthAndApollo(
;({ container } = renderWithAuthAndApollo(
<DefaultLayout>
<h1>Test Page</h1>
</DefaultLayout>,
{},
getUserMock
)
))
// need to wait for the query to finish so waiting for banner to display
await waitFor(() =>
expect(screen.getByTestId('govBanner')).toBeInTheDocument()
Expand All @@ -65,7 +66,7 @@ describe('DefaultLayout component', () => {
screen.getByRole('link', { name: 'Skip to main content' })
).toHaveAttribute('href', '#main-content')

expect(screen.getByRole('main')).toHaveAttribute('id', 'main-content')
expect(container.querySelector('div#main-content')).toBeInTheDocument()
})

it('renders a feedback link', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/layout/DefaultLayout/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const DefaultLayout = ({
<GovBanner tld=".mil" />
<Header />
</div>
<main id="main-content">
<main>
<PageHeader>
<PersonalData userDisplayName={displayName} />
</PageHeader>
Expand All @@ -62,7 +62,7 @@ const DefaultLayout = ({
<Grid desktop={{ col: 2 }} style={{ minWidth: '221px' }}>
<PageNav />
</Grid>
<Grid desktop={{ col: true }}>
<Grid id="main-content" desktop={{ col: true }}>
{/* PAGE CONTENT */}
{children}
</Grid>
Expand Down

0 comments on commit c2e8e8e

Please sign in to comment.