Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PXBF-1904-polite-a11y-page-titles: update to a11y titles, as we are u… #2076

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions benefit-finder/src/Routes/ResultsView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ 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, a11yTitles } from '@utils'
import { Banner } from '@components'

import { dataLayerUtils, handleSurvey, domReady, politeTitles } from '@utils'

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

/**
Expand Down Expand Up @@ -74,6 +73,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 @@ -110,7 +110,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,
}
Loading