Skip to content

Commit 6b5c979

Browse files
authored
fix: wcag 4.1.2 requirement, add box-shadow to trip card focus (#706)
* fix: wcag 4.1.2 requirement, add box-shadow to trip card focus * formatting...
1 parent f14d742 commit 6b5c979

4 files changed

Lines changed: 35 additions & 7 deletions

File tree

src/components/labled-input/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function LabeledInput({
2525
const isError = typeof validationError !== 'undefined';
2626
const postfix = useId();
2727

28+
const inputId = 'input-' + postfix;
2829
const errorLabel = 'error-' + postfix;
2930

3031
const validationStatusProps: React.JSX.IntrinsicElements['input'] = isError
@@ -37,8 +38,11 @@ export default function LabeledInput({
3738
[style['container--error']]: isError,
3839
})}
3940
>
40-
<label className={style.label}>{label}</label>
41+
<label className={style.label} htmlFor={inputId}>
42+
{label}
43+
</label>
4144
<input
45+
id={inputId}
4246
className={style.input}
4347
type="text"
4448
placeholder={placeholder}

src/page-modules/assistant/trip/trip-pattern/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,16 @@ export default function TripPattern({
109109
<div ref={ref} className={style.tripPatternContainer}>
110110
<motion.div
111111
id={`${id}-details-region`}
112-
role="region"
112+
role="button"
113+
tabIndex={0}
113114
onClick={() => setIsOpen(!isOpen)}
115+
onKeyDown={(e) => {
116+
if (e.key === 'Enter' || e.key === ' ') {
117+
e.preventDefault();
118+
setIsOpen(!isOpen);
119+
}
120+
}}
121+
aria-expanded={isOpen}
114122
className={className}
115123
data-testid={testId}
116124
initial={{ opacity: 0, x: -10 }}
@@ -119,14 +127,14 @@ export default function TripPattern({
119127
transition={{
120128
delay, // staggerChildren on parent only works first render
121129
}}
122-
aria-label={tripSummary(
130+
aria-label={`${tripSummary(
123131
tripPattern,
124132
t,
125133
language,
126134
tripIsInPast,
127135
index + 1,
128136
isCancelled,
129-
)}
137+
)}. ${isOpen ? t(PageText.Assistant.trip.tripPattern.activateToCollapse) : t(PageText.Assistant.trip.tripPattern.activateToExpand)}`}
130138
>
131139
<TripPatternHeader
132140
tripPattern={tripPattern}
@@ -243,7 +251,7 @@ export default function TripPattern({
243251
</Typo.span>
244252
</div>
245253
</div>
246-
<footer className={style.footer} onClick={() => setIsOpen(!isOpen)}>
254+
<footer className={style.footer}>
247255
<div className={style.info__container}>
248256
{tripIsInPast && (
249257
<Tag
@@ -273,8 +281,8 @@ export default function TripPattern({
273281
: t(PageText.Assistant.trip.tripPattern.seeMore)
274282
}
275283
buttonProps={{
276-
'aria-controls': `${id}-details-region`,
277-
'aria-expanded': isOpen,
284+
tabIndex: -1,
285+
'aria-hidden': true,
278286
}}
279287
className={style.seeMoreButton}
280288
size={'pill'}

src/page-modules/assistant/trip/trip-pattern/trip-pattern.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
.tripPattern:hover {
1515
cursor: pointer;
1616
}
17+
.tripPattern:focus {
18+
outline: 0;
19+
box-shadow: inset 0 0 0 token('border.width.medium')
20+
token('color.interactive.2.outline.background');
21+
border-radius: token('border.radius.regular');
22+
}
1723

1824
.header {
1925
display: flex;

src/translations/pages/assistant.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ const AssistantInternal = {
175175
),
176176
seeMore: _('Se mer', 'See more', 'Sjå meir'),
177177
seeLess: _('Se mindre', 'See less', 'Sjå mindre'),
178+
activateToExpand: _(
179+
'Trykk for å utvide',
180+
'Activate to expand',
181+
'Trykk for å utvide',
182+
),
183+
activateToCollapse: _(
184+
'Trykk for å lukke',
185+
'Activate to collapse',
186+
'Trykk for å lukke',
187+
),
178188
hasSituationsTip: _(
179189
'Denne reisen har driftsmeldinger. Se detaljer for mer info',
180190
'There are service messages affecting your journey. See details for more info ',

0 commit comments

Comments
 (0)