Skip to content

Commit 9ba8b8f

Browse files
fixed focus issue
1 parent a2b93b6 commit 9ba8b8f

File tree

3 files changed

+60
-14
lines changed

3 files changed

+60
-14
lines changed

packages/cpt-ui/src/components/EpsCard.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function EpsCard({role, link}: EpsCardProps) {
2020
const navigate = useNavigate()
2121
const authContext = useAuth()
2222

23-
const handleSetSelectedRole = async (e: React.MouseEvent) => {
23+
const handleSetSelectedRole = async (e: React.MouseEvent | React.KeyboardEvent) => {
2424
e.preventDefault()
2525
try {
2626
await authContext.updateSelectedRole(role)
@@ -42,25 +42,35 @@ export default function EpsCard({role, link}: EpsCardProps) {
4242
noODSCode,
4343
noOrgName,
4444
noRoleName,
45-
noAddress
45+
noAddress,
46+
odsLabel
4647
} = EPS_CARD_STRINGS
4748

4849
return (
4950
<Card clickable className="eps-card" data-testid="eps-card">
5051
<Card.Content>
5152
<Row className="nhsuk-grid-row eps-card__content">
52-
5353
<Col width='one-half'>
54-
<Card.Link
55-
href={link}
56-
onClick={handleSetSelectedRole}
54+
<div
55+
className="eps-card__org-focus-area"
56+
tabIndex={0}
57+
onKeyDown={(e) => {
58+
if (e.key === "Enter" || e.key === " ") {
59+
e.preventDefault()
60+
handleSetSelectedRole(e)
61+
}
62+
}}
63+
onClick={(e) => {
64+
e.stopPropagation()
65+
handleSetSelectedRole(e)
66+
}}
5767
>
58-
<Card.Heading className="nhsuk-heading-s">
59-
{role.org_name || noOrgName}
60-
<br />
61-
(ODS: {role.org_code || noODSCode})
62-
</Card.Heading>
63-
</Card.Link>
68+
<div className="eps-card__org-name">
69+
<Card.Heading className="nhsuk-heading-s">
70+
{role.org_name || noOrgName} ({odsLabel}: {role.org_code || noODSCode})
71+
</Card.Heading>
72+
</div>
73+
</div>
6474
<Card.Description className="eps-card__roleName">
6575
{role.role_name || noRoleName}
6676
</Card.Description>

packages/cpt-ui/src/constants/ui-strings/CardStrings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ export const EPS_CARD_STRINGS = {
3333
noOrgName: "NO ORG NAME",
3434
noODSCode: "No ODS code",
3535
noRoleName: "No role name",
36-
noAddress: "Address not found"
36+
noAddress: "Address not found",
37+
odsLabel: "ODS"
3738
}

packages/cpt-ui/src/styles/card.scss

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.eps-card {
2-
margin-bottom: 1.5rem;
2+
margin-bottom: 1rem;
33
padding: 0rem;
44

55
&__content {
@@ -8,6 +8,39 @@
88
align-items: flex-start;
99
}
1010

11+
&__org-focus-area {
12+
outline: none;
13+
14+
&:hover {
15+
.eps-card__org-name {
16+
color: #7c2d12 !important;
17+
text-decoration: none !important;
18+
}
19+
}
20+
21+
&:focus {
22+
outline: 3px solid #ffeb3b;
23+
outline-offset: 0;
24+
box-shadow: inset 0 -4px 0 0 #212b32;
25+
background-color: #ffeb3b;
26+
27+
.eps-card__org-name {
28+
text-decoration: none !important;
29+
}
30+
31+
.nhsuk-heading-s {
32+
color: #212b32;
33+
text-decoration: none;
34+
}
35+
}
36+
}
37+
38+
&__org-name {
39+
color: #005eb8;
40+
text-decoration: underline;
41+
cursor: pointer;
42+
}
43+
1144
&__roleName {
1245
margin-top: 0.5rem;
1346
margin-bottom: 24px;
@@ -29,6 +62,8 @@
2962
}
3063
}
3164

65+
66+
3267
&__link {
3368
background-color: #ffffff;
3469
border: 1px solid transparent;

0 commit comments

Comments
 (0)