Skip to content

Commit

Permalink
PXBF-1904-polite-a11y-page-titles: update to a11y titles, as we are u…
Browse files Browse the repository at this point in the history
…sing assertive region
  • Loading branch information
scottqueen-bixal committed Jan 22, 2025
1 parent 5279f7f commit de0d014
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
9 changes: 7 additions & 2 deletions benefit-finder/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>React App | Benefit Finder</title>
<title>REACT APP | Benefit finder: death of a loved one | USAGov</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Public+Sans:wght@200;400;600;700;800&family=Tilt+Warp&display=swap');
</style>
Expand All @@ -24,7 +24,12 @@
</script>
</head>
<body>
<div id="live-region" aria-live="polite" class="usa-sr-only" tabindex="-1">
<div
id="live-region"
aria-live="assertive"
class="usa-sr-only"
tabindex="-1"
>
Benefit finder: death of a loved one | USAGov
</div>
<script type="module" src="./src/index.jsx"></script>
Expand Down
4 changes: 2 additions & 2 deletions benefit-finder/src/Routes/Intro/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useContext } from 'react'
import { useNavigate, useLocation } from 'react-router'
import { RouteContext } from '@/App'
import { dataLayerUtils, politeTitles } from '@utils'
import { dataLayerUtils, a11yTitles } from '@utils'
import { useScrollToAnchor } from '@hooks'
import PropTypes from 'prop-types'
import {
Expand Down Expand Up @@ -51,7 +51,7 @@ const Intro = ({ content, ui, hasQueryParams }) => {
event: intro.event,
bfData: { pageView: intro.bfData.pageView, viewTitle: title },
})
politeTitles(title)
a11yTitles(title)
}, [hasQueryParams])

return (
Expand Down
4 changes: 2 additions & 2 deletions benefit-finder/src/Routes/LifeEventSection/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
dataLayerUtils,
errorHandling,
handleSurvey,
politeTitles,
a11yTitles,
} from '@utils'
import { useHandleUnload, useResetElement, useScrollToAnchor } from '@hooks'
import * as apiCalls from '@api/apiCalls'
Expand Down Expand Up @@ -266,7 +266,7 @@ const LifeEventSection = ({ data, handleData, ui }) => {
viewTitle: data[index]?.section.heading,
},
})
politeTitles(location.pathname, locale)
a11yTitles(location.pathname, locale)
!location.hash && resetElement.current?.focus()
!location.hash && window.scrollTo(0, 0)
}, [location])
Expand Down
5 changes: 3 additions & 2 deletions benefit-finder/src/Routes/ResultsView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useResetElement, useScrollToAnchor } from '@hooks'
import * as apiCalls from '@api/apiCalls'
import PropTypes from 'prop-types'
import { Results } from './components/index'
import { dataLayerUtils, handleSurvey, domReady, politeTitles } from '@utils'
import { dataLayerUtils, handleSurvey, domReady, a11yTitles } from '@utils'

// Results View is a single view with three states, eligible, not eligible, and zero benefits

Expand Down Expand Up @@ -67,6 +67,7 @@ const ResultsView = ({
useEffect(() => {
!location.hash && resetElement.current?.focus()
!location.hash && window.scrollTo(0, 0)
a11yTitles(location.pathname, locale)
setExpandAll(false)
}, [location])

Expand Down Expand Up @@ -103,7 +104,7 @@ const ResultsView = ({
...eligibilityCount,
},
})
politeTitles(location.pathname, locale)
a11yTitles(location.pathname, locale)
}, [notEligibleView, eligibilityCount])

useEffect(() => {
Expand Down
5 changes: 3 additions & 2 deletions benefit-finder/src/Routes/VerifySelectionsView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useContext } from 'react'
import { useNavigate, useLocation } from 'react-router'
import PropTypes from 'prop-types'
import { RouteContext } from '@/App'
import { parseDate, dataLayerUtils, handleSurvey, politeTitles } from '@utils'
import { parseDate, dataLayerUtils, handleSurvey, a11yTitles } from '@utils'
import { useResetElement, useScrollToAnchor } from '@hooks'
import * as apiCalls from '@api/apiCalls'
import { Heading, Button } from '@components'
Expand Down Expand Up @@ -108,6 +108,7 @@ const VerifySelectionsView = ({ ui, data }) => {
useEffect(() => {
!location.hash && resetElement.current?.focus()
!location.hash && window.scrollTo(0, 0)
a11yTitles(location.pathname, locale)
}, [location])

// handle dataLayer
Expand All @@ -119,7 +120,7 @@ const VerifySelectionsView = ({ ui, data }) => {
viewTitle: verifySelectionsView?.heading,
},
})
politeTitles(location.pathname, locale)
a11yTitles(location.pathname, locale)
}, [])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const politeTitles = (location, locale) => {
const a11yTitles = (location, locale) => {
// create a hidden liveRegion to announce titles to screen-readers
const liveRegion = document.getElementById('live-region')

Expand Down Expand Up @@ -29,4 +29,4 @@ const politeTitles = (location, locale) => {
return
}

export default politeTitles
export default a11yTitles
4 changes: 2 additions & 2 deletions benefit-finder/src/shared/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import dataLayerUtils from './dataLayerUtils'
import dateInputValidation from './dateInputValidation'
import handleSurvey from './handleSurvey'
import parseDate from './parseDate'
import politeTitles from './politeTitles'
import a11yTitles from './a11yTitles'
import scrollLock from './scrollLock'
import windowSize from './windowSize'

Expand All @@ -21,7 +21,7 @@ export {
dateInputValidation,
handleSurvey,
parseDate,
politeTitles,
a11yTitles,
scrollLock,
windowSize,
}

0 comments on commit de0d014

Please sign in to comment.