-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-non-tabbable-highlights
- Loading branch information
Showing
26 changed files
with
345 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { renderToDom } from '../../test/reactutils'; | ||
// import { act } from 'react-dom/test-utils'; | ||
import { initialState } from '../reducer'; | ||
import createTestStore from '../../test/createTestStore'; | ||
import PageTitleConfirmation from './PageTitleConfirmation'; | ||
import TestContainer from '../../test/TestContainer'; | ||
import { setHead } from '../head/actions'; | ||
|
||
describe('PageTitleConfirmation', () => { | ||
it('skips blank, skips first non-blank, announces subsequent', async() => { | ||
const state = { | ||
...initialState, | ||
}; | ||
|
||
state.head.title = 'initial'; | ||
const store = createTestStore(state); | ||
|
||
store.dispatch(setHead({...initialState.head, title: ''})); | ||
const component = renderToDom( | ||
<TestContainer store={store}> | ||
<PageTitleConfirmation className='any' /> | ||
</TestContainer> | ||
); | ||
|
||
expect(component.node.textContent).toBe(''); | ||
store.dispatch(setHead({...initialState.head, title: 'initial'})); | ||
expect(component.node.textContent).toBe(''); | ||
store.dispatch(setHead({...initialState.head, title: 'something'})); | ||
expect(component.node.textContent).toBe('Loaded page something'); | ||
component.unmount(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { hiddenButAccessible } from '../theme'; | ||
import { AppState } from '../types'; | ||
import styled from 'styled-components'; | ||
import { connect } from 'react-redux'; | ||
import { title as titleSelector } from '../head/selectors'; | ||
|
||
function PageTitleConfirmation({ | ||
className, | ||
title, | ||
}: { | ||
className: string; | ||
title: string; | ||
}) { | ||
const skipFirst = React.useRef(true); | ||
const message = React.useMemo(() => { | ||
if (!title) { | ||
return ''; | ||
} | ||
if (skipFirst.current) { | ||
skipFirst.current = false; | ||
return ''; | ||
} | ||
return `Loaded page ${title}`; | ||
}, [title]); | ||
|
||
return ( | ||
<div id='page-title-confirmation' className={className} aria-live='polite'> | ||
{message} | ||
</div> | ||
); | ||
} | ||
|
||
export default connect((state: AppState) => ({title: titleSelector(state)}))(styled( | ||
PageTitleConfirmation | ||
)` | ||
${hiddenButAccessible} | ||
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.