Skip to content

Commit

Permalink
Merge pull request #2075 from GSA/2065-fix-skip-to-h1-tab-order
Browse files Browse the repository at this point in the history
2065 fix skip to h1 tab order
  • Loading branch information
scottqueen-bixal authored Jan 22, 2025
2 parents 5279f7f + 822307f commit c0833dc
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 58 deletions.
1 change: 1 addition & 0 deletions benefit-finder/cspell-dictionary/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ buildpacks
webfonts
hkshshslhshjksh
kjgljjlhkhgljgjh
GTMIs
1 change: 0 additions & 1 deletion benefit-finder/cypress/support/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { pageObjects } from './pageObjects'
import * as EN_LOCALE_DATA from '../../../benefit-finder/src/shared/locales/en/en.json'

export function filterDataLayerByEvent(eventName) {
return cy.window().then(window => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,6 @@

exports[`Results > renders a match to the previous snapshot 1`] = `
<DocumentFragment>
<div
class="bf-banner"
>
<div
class="bf-grid-container grid-container"
>
<h1
aria-level="1"
class="bf-banner-heading "
id="skip-to-h1"
role="heading"
>
Benefits you did not qualify for
</h1>
<div
class="bf-banner-description"
>
<div>
<p>
According to your answers you are not eligible for these benefits.
</p>
</div>
</div>
</div>
</div>
<div
class="bf-grid-container grid-container"
data-testid="bf-results-view"
Expand Down
30 changes: 0 additions & 30 deletions benefit-finder/src/Routes/ResultsView/components/Results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Button,
EmailTrigger,
Heading,
Banner,
ShareTrigger,
RelativeBenefitList,
} from '@components'
Expand Down Expand Up @@ -35,30 +34,6 @@ const Results = ({
const ROUTES = useContext(RouteContext)
const navigate = useNavigate()
// Results view components
const ResultsBannerBlock = ({ notEligibleView, zeroBenefitsResult, ui }) => {
const { eligible, notEligible, zeroBenefits } = ui
return (
<Banner
heading={
notEligibleView === false
? (zeroBenefitsResult && zeroBenefits?.eligible.banner.heading) ||
eligible?.banner.heading
: (zeroBenefitsResult &&
zeroBenefits?.notEligible.banner.heading) ||
notEligible?.banner.heading
}
description={
notEligibleView === false
? (zeroBenefitsResult &&
zeroBenefits?.eligible.banner.description) ||
eligible?.banner.description
: (zeroBenefitsResult &&
zeroBenefits?.notEligible.banner.description) ||
notEligible?.banner.description
}
/>
)
}

const ResultsHeadingBlock = ({ zeroBenefitsResult, notEligibleView, ui }) => {
const { notEligible, eligible, summaryBox, zeroBenefits } = ui
Expand Down Expand Up @@ -187,11 +162,6 @@ const Results = ({

return (
<>
<ResultsBannerBlock
notEligibleView={notEligibleView}
zeroBenefitsResult={zeroBenefitsResult}
ui={ui}
/>
<div
className="bf-grid-container grid-container"
data-testid="bf-results-view"
Expand Down
29 changes: 27 additions & 2 deletions benefit-finder/src/Routes/ResultsView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useResetElement, useScrollToAnchor } from '@hooks'
import * as apiCalls from '@api/apiCalls'
import PropTypes from 'prop-types'
import { Results } from './components/index'
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 All @@ -29,11 +31,11 @@ const ResultsView = ({
const [eligibilityCount, setEligibilityCount] = useState(null)
const [zeroBenefitsResult, setZeroBenefitsResult] = useState(null)
const { resultsView } = dataLayerUtils.dataLayerStructure
const { eligible, notEligible, zeroBenefits } = ui
const navigate = useNavigate()
const location = useLocation()
const ROUTES = useContext(RouteContext)
const locale = apiCalls.GET.Language()
useScrollToAnchor(location)

/**
* a hook that handles our open state of the accordions in our group
Expand All @@ -43,6 +45,7 @@ const ResultsView = ({
const [isExpandAll, setExpandAll] = useState(false)

const resetElement = useResetElement()
useScrollToAnchor(location)

// some data-test values
// how many questions were values provided for
Expand All @@ -63,6 +66,10 @@ const ResultsView = ({
: navigate(`/${ROUTES.indexPath}/${ROUTES.resultsPaths.notEligiblePath}`)
}

useEffect(() => {
resetElement.current?.focus()
}, [resetElement])

// handle location change
useEffect(() => {
!location.hash && resetElement.current?.focus()
Expand Down Expand Up @@ -132,6 +139,25 @@ const ResultsView = ({
data-testid="bf-result-view"
{...testAttributes}
>
<Banner
heading={
notEligibleView === false
? (zeroBenefitsResult && zeroBenefits?.eligible.banner.heading) ||
eligible?.banner.heading
: (zeroBenefitsResult &&
zeroBenefits?.notEligible.banner.heading) ||
notEligible?.banner.heading
}
description={
notEligibleView === false
? (zeroBenefitsResult &&
zeroBenefits?.eligible.banner.description) ||
eligible?.banner.description
: (zeroBenefitsResult &&
zeroBenefits?.notEligible.banner.description) ||
notEligible?.banner.description
}
/>
<Results
notEligibleView={notEligibleView}
zeroBenefitsResult={zeroBenefitsResult}
Expand All @@ -140,7 +166,6 @@ const ResultsView = ({
isExpandAll={isExpandAll}
setExpandAll={setExpandAll}
relevantBenefits={relevantBenefits}
resetElement={resetElement}
data={data}
ui={ui}
/>
Expand Down

0 comments on commit c0833dc

Please sign in to comment.