Skip to content

Commit 398246c

Browse files
Chore/remove badges from tab order (#9643)
Makes badges not tabbable by default instead of tabbable by default. Turns out, badges aren't tabbable by default and they never were until I made them as much (for some reason that I don't quite understand now). Anyway, I've gone through the list of uses for the Badge element and made any element that should be reachable by tab either have an explicit tab index (if it's within a tooltip, for instance), or be wrapped in a Link (instead of having an on-click handler). The two places I've wrapped it in a link, I've also gone and changed the item group to be a list (for HTML semantics). I've also updated some spacing for the profile tab. Application list (one is before, one is after. don't remember which is which; it's now a list): ![image](https://github.com/user-attachments/assets/66fdabf7-7a80-46cb-b302-6242c16ad43e) ![image](https://github.com/user-attachments/assets/660506ce-0ec4-417f-bb3a-3fbf23d5591c) Profile page (now a list + improved spacing) Before: ![image](https://github.com/user-attachments/assets/17a841e6-d500-410e-8f11-4c78ca0e9e12) ![image](https://github.com/user-attachments/assets/38a60e67-682e-45b5-9312-f4c2013192bb) After: ![image](https://github.com/user-attachments/assets/602f3d06-0b7e-4a10-9958-fb565fb6d06b) ![image](https://github.com/user-attachments/assets/67c7d39c-cdf9-4586-98d9-63ceff4fd867)
1 parent fc03836 commit 398246c

File tree

9 files changed

+80
-55
lines changed

9 files changed

+80
-55
lines changed

frontend/src/component/admin/network/NetworkTrafficUsage/RequestSummary.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export const RequestSummary: FC<Props> = ({
8888
: 'error'
8989
: 'neutral'
9090
}
91-
tabIndex={-1}
9291
>
9392
{usageTotal.toLocaleString(
9493
locationSettings.locale ?? 'en-US',

frontend/src/component/application/ApplicationOverview.tsx

+25-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ApplicationIssues } from './ApplicationIssues/ApplicationIssues';
1414
import { ApplicationChart } from './ApplicationChart';
1515
import TopicOutlinedIcon from '@mui/icons-material/TopicOutlined';
1616
import { Badge } from '../common/Badge/Badge';
17-
import { useNavigate } from 'react-router-dom';
17+
import { Link, useNavigate } from 'react-router-dom';
1818
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
1919
import { useEffect } from 'react';
2020
import { useFeedback } from '../feedbackNew/useFeedback';
@@ -35,11 +35,22 @@ const ApplicationContainer = styled(Box)(({ theme }) => ({
3535
alignSelf: 'stretch',
3636
}));
3737

38-
const ProjectContainer = styled(Box)(({ theme }) => ({
38+
const ProjectContainer = styled('ul')(({ theme }) => ({
39+
padding: 0,
3940
display: 'flex',
4041
alignItems: 'center',
4142
gap: theme.spacing(2),
4243
alignSelf: 'stretch',
44+
listStyle: 'none',
45+
}));
46+
47+
const StyledBadgeLink = styled(Link)(({ theme }) => ({
48+
':hover,:focus-visible': {
49+
outline: 'none',
50+
'> *': {
51+
outline: `1px solid ${theme.palette.primary.main}`,
52+
},
53+
},
4354
}));
4455

4556
const ApplicationHeader = styled('div')(({ theme }) => ({
@@ -97,18 +108,18 @@ const ApplicationOverview = () => {
97108
<ProjectContainer>
98109
Application is connected to these projects:
99110
{data.projects.map((project) => (
100-
<Badge
101-
sx={{ cursor: 'pointer' }}
102-
key={project}
103-
onClick={(e) => {
104-
e.preventDefault();
105-
navigate(`/projects/${project}`);
106-
}}
107-
color='secondary'
108-
icon={<TopicOutlinedIcon />}
109-
>
110-
{project}
111-
</Badge>
111+
<li key={project}>
112+
<StyledBadgeLink
113+
to={`/projects/${project}`}
114+
>
115+
<Badge
116+
color='secondary'
117+
icon={<TopicOutlinedIcon />}
118+
>
119+
{project}
120+
</Badge>
121+
</StyledBadgeLink>
122+
</li>
112123
))}
113124
</ProjectContainer>
114125
<Button

frontend/src/component/common/Badge/Badge.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,12 @@ export const Badge: FC<IBadgeProps> = forwardRef(
9797
className,
9898
sx,
9999
children,
100-
tabIndex = 0,
101100
...props
102101
}: IBadgeProps,
103102
ref: ForwardedRef<HTMLDivElement>,
104103
) => (
105104
<StyledBadge
106105
as={as}
107-
tabIndex={tabIndex}
108106
color={color}
109107
icon={icon}
110108
className={className}

frontend/src/component/common/RoleBadge/RoleBadge.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ export const RoleBadge = ({ roleId, hideIcon, children }: IRoleBadgeProps) => {
2727

2828
return (
2929
<HtmlTooltip title={<RoleDescription roleId={roleId} tooltip />} arrow>
30-
<Badge color='success' icon={icon} sx={{ cursor: 'pointer' }}>
30+
<Badge
31+
tabIndex={0}
32+
color='success'
33+
icon={icon}
34+
sx={{ cursor: 'pointer' }}
35+
>
3136
{role.name}
3237
</Badge>
3338
</HtmlTooltip>

frontend/src/component/common/Table/cells/FeatureOverviewCell/FeatureOverviewCell.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ export const PrimaryFeatureInfo: FC<{
342342
/>
343343
{archivedAt && (
344344
<HtmlTooltip arrow title={archivedDate} describeChild>
345-
<Badge color='neutral'>Archived</Badge>
345+
<Badge tabIndex={0} color='neutral'>
346+
Archived
347+
</Badge>
346348
</HtmlTooltip>
347349
)}
348350
</FeatureNameAndType>

frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureDetails/FeatureDetails.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ export const FeatureDetails = ({
117117
<p>
118118
{feature?.strategies?.result !== 'unknown' ? (
119119
<PlaygroundResultChip
120-
tabindex={-1}
121120
enabled={feature.isEnabled}
122121
label={feature.isEnabled ? 'True' : 'False'}
123122
/>
124123
) : (
125124
<PlaygroundResultChip
126-
tabindex={-1}
127125
enabled='unknown'
128126
label={'Unknown'}
129127
showIcon={false}

frontend/src/component/playground/Playground/PlaygroundResultsTable/PlaygroundResultChip/LegacyPlaygroundResultChip.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ interface IResultChipProps {
1414
label: string;
1515
// Result icon - defaults to true
1616
showIcon?: boolean;
17-
tabindex?: number;
1817
}
1918

2019
export const PlaygroundResultChip: VFC<IResultChipProps> = ({
2120
enabled,
2221
label,
2322
showIcon = true,
24-
tabindex,
2523
}) => {
2624
const theme = useTheme();
2725
const flagOverviewRedesign = useUiFlag('flagOverviewRedesign');
@@ -73,19 +71,14 @@ export const PlaygroundResultChip: VFC<IResultChipProps> = ({
7371
condition={typeof enabled === 'boolean' && Boolean(enabled)}
7472
show={
7573
<Badge
76-
tabIndex={tabindex}
7774
color='success'
7875
icon={showIcon ? icon : undefined}
7976
>
8077
{label}
8178
</Badge>
8279
}
8380
elseShow={
84-
<Badge
85-
color='error'
86-
icon={showIcon ? icon : undefined}
87-
tabIndex={tabindex}
88-
>
81+
<Badge color='error' icon={showIcon ? icon : undefined}>
8982
{label}
9083
</Badge>
9184
}

frontend/src/component/playground/Playground/PlaygroundResultsTable/PlaygroundResultChip/PlaygroundResultChip.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const PlaygroundResultChip: FC<ResultChipProps> = ({
3232

3333
return (
3434
<Badge
35-
tabIndex={-1}
3635
color={color}
3736
icon={
3837
showIcon ? (

frontend/src/component/user/Profile/ProfileTab/ProfileTab.tsx

+45-25
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useProfile } from 'hooks/api/getters/useProfile/useProfile';
1515
import { useLocationSettings } from 'hooks/useLocationSettings';
1616
import type { IUser } from 'interfaces/user';
1717
import TopicOutlinedIcon from '@mui/icons-material/TopicOutlined';
18-
import { useNavigate } from 'react-router-dom';
18+
import { Link, useNavigate } from 'react-router-dom';
1919
import { PageContent } from 'component/common/PageContent/PageContent';
2020
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
2121
import { RoleBadge } from 'component/common/RoleBadge/RoleBadge';
@@ -56,14 +56,19 @@ const StyledSectionLabel = styled(Typography)(({ theme }) => ({
5656
const StyledAccess = styled('div')(({ theme }) => ({
5757
display: 'flex',
5858
flexDirection: 'row',
59+
gap: theme.spacing(2),
5960
'& > div > p': {
6061
marginBottom: theme.spacing(1.5),
6162
},
6263
}));
6364

64-
const StyledBadge = styled(Badge)(({ theme }) => ({
65-
cursor: 'pointer',
66-
marginRight: theme.spacing(1),
65+
const StyledBadgeLink = styled(Link)(({ theme }) => ({
66+
':hover,:focus-visible': {
67+
outline: 'none',
68+
'> *': {
69+
outline: `2px solid ${theme.palette.primary.main}`,
70+
},
71+
},
6772
}));
6873

6974
const StyledDivider = styled('div')(({ theme }) => ({
@@ -86,6 +91,14 @@ interface IProfileTabProps {
8691
user: IUser;
8792
}
8893

94+
const ProjectList = styled('ul')(({ theme }) => ({
95+
listStyle: 'none',
96+
padding: 0,
97+
display: 'flex',
98+
flexFlow: 'row wrap',
99+
gap: theme.spacing(1),
100+
}));
101+
89102
export const ProfileTab = ({ user }: IProfileTabProps) => {
90103
const { profile, refetchProfile } = useProfile();
91104
const navigate = useNavigate();
@@ -158,33 +171,40 @@ export const ProfileTab = ({ user }: IProfileTabProps) => {
158171
<Typography variant='body2'>Projects</Typography>
159172
<ConditionallyRender
160173
condition={Boolean(profile?.projects.length)}
161-
show={profile?.projects.map((project) => (
162-
<Tooltip
163-
key={project}
164-
title='View project'
165-
arrow
166-
placement='bottom-end'
167-
describeChild
168-
>
169-
<StyledBadge
170-
onClick={(e) => {
171-
e.preventDefault();
172-
navigate(`/projects/${project}`);
173-
}}
174-
color='secondary'
175-
icon={<TopicOutlinedIcon />}
176-
>
177-
{project}
178-
</StyledBadge>
179-
</Tooltip>
180-
))}
174+
show={
175+
<ProjectList>
176+
{profile?.projects.map((project) => (
177+
<li key={project}>
178+
<Tooltip
179+
title='View project'
180+
arrow
181+
placement='bottom-end'
182+
describeChild
183+
>
184+
<StyledBadgeLink
185+
to={`/projects/${project}`}
186+
>
187+
<Badge
188+
color='secondary'
189+
icon={
190+
<TopicOutlinedIcon />
191+
}
192+
>
193+
{project}
194+
</Badge>
195+
</StyledBadgeLink>
196+
</Tooltip>
197+
</li>
198+
))}
199+
</ProjectList>
200+
}
181201
elseShow={
182202
<Tooltip
183203
title='You are not assigned to any projects'
184204
arrow
185205
describeChild
186206
>
187-
<Badge>No projects</Badge>
207+
<Badge tabIndex={0}>No projects</Badge>
188208
</Tooltip>
189209
}
190210
/>

0 commit comments

Comments
 (0)