Skip to content

Commit 2636ad8

Browse files
fix(frontend): accessibility improvements for FeatureSidebar (#133)
- hierarchical heading structure, for users that navigate by heading. - fix unlabelled combobox inputs. - add `tabindex` to scrolling tables.
1 parent 58f99a4 commit 2636ad8

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

frontend/src/details/features/adaptation/AdaptationSection.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export const AdaptationSection = ({ fd }) => {
7676
<>
7777
<Box py={2}>
7878
<Box position="relative">
79-
<Typography variant="h6">Adaptation Options</Typography>
79+
<Typography variant="h6" component="h2">
80+
Adaptation Options
81+
</Typography>
8082
<IconButton
8183
sx={{
8284
position: 'absolute',
@@ -101,7 +103,7 @@ export const AdaptationSection = ({ fd }) => {
101103
const filteredOptions = options.filter((o) => o.adaptation_name === name);
102104
return (
103105
<>
104-
<Typography variant="subtitle2" component="h2" sx={{ mt: 2, mb: 1 }}>
106+
<Typography variant="subtitle2" component="h3" sx={{ mt: 2, mb: 1 }}>
105107
{name}
106108
</Typography>
107109
<Typography variant="body2" component="p" sx={{ mb: 2 }}>

frontend/src/details/features/adaptation/AdaptationTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const padding = { px: 0.25, py: 0.25 };
77
export const AdaptationTable = ({ options }) => {
88
const numDays = 15;
99
return (
10-
<TableContainer sx={{ maxHeight: 260 }}>
10+
<TableContainer sx={{ maxHeight: 260 }} tabIndex={0}>
1111
<Table size="small" padding="none" stickyHeader>
1212
<TableHead>
1313
<TableRow>

frontend/src/details/features/damages/DamageTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from
22
import { numFormat, numRangeFormat } from 'lib/helpers';
33
const padding = { px: 0.25, py: 0.25 };
44
export const DamageTable = ({ damages }) => (
5-
<TableContainer sx={{ maxHeight: 260 }}>
5+
<TableContainer sx={{ maxHeight: 260 }} tabIndex={0}>
66
<Table size="small" padding="none" stickyHeader>
77
<TableHead>
88
<TableRow>

frontend/src/details/features/damages/DamagesSection.tsx

+16-8
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ export const DamagesSection = ({ fd }) => {
193193
<>
194194
<Box py={2}>
195195
<Box position="relative">
196-
<Typography variant="h6">Risk</Typography>
196+
<Typography variant="h6" component="h2">
197+
Risk
198+
</Typography>
197199
<IconButton
198200
sx={{
199201
position: 'absolute',
@@ -210,9 +212,9 @@ export const DamagesSection = ({ fd }) => {
210212
</Box>
211213
{hazards.length ? (
212214
<FormControl fullWidth sx={{ my: 2 }} disabled={hazards.length === 1}>
213-
<InputLabel>Hazard</InputLabel>
215+
<InputLabel id={`feature-${fd.id}-hazard`}>Hazard</InputLabel>
214216
<Select
215-
label="Hazard"
217+
labelId={`feature-${fd.id}-hazard`}
216218
value={selectedHazard ?? ''}
217219
onChange={(e) => setSelectedHazard(e.target.value as string)}
218220
>
@@ -227,7 +229,9 @@ export const DamagesSection = ({ fd }) => {
227229
{selectedData ? (
228230
<>
229231
<Box mt={1}>
230-
<Typography variant="subtitle2">Expected Annual Damages</Typography>
232+
<Typography component="h3" variant="subtitle2">
233+
Expected Annual Damages
234+
</Typography>
231235
<ExpectedDamageChart
232236
data={{
233237
table: selectedData,
@@ -245,7 +249,9 @@ export const DamagesSection = ({ fd }) => {
245249
</Box>
246250
{has_eael ? (
247251
<Box mt={1}>
248-
<Typography variant="subtitle2">Expected Annual Economic Losses</Typography>
252+
<Typography component="h3" variant="subtitle2">
253+
Expected Annual Economic Losses
254+
</Typography>
249255
<ExpectedDamageChart
250256
data={{
251257
table: selectedData,
@@ -274,7 +280,9 @@ export const DamagesSection = ({ fd }) => {
274280
</Box>
275281
<Box py={2}>
276282
<Box position="relative">
277-
<Typography variant="h6">Return Period Damages</Typography>
283+
<Typography variant="h6" component="h2">
284+
Return Period Damages
285+
</Typography>
278286
<IconButton
279287
sx={{
280288
position: 'absolute',
@@ -295,9 +303,9 @@ export const DamagesSection = ({ fd }) => {
295303
</Box>
296304
{epochs.length ? (
297305
<FormControl fullWidth sx={{ my: 2 }} disabled={epochs.length === 1}>
298-
<InputLabel>Epoch</InputLabel>
306+
<InputLabel id={`feature-${fd.id}-epoch`}>Epoch</InputLabel>
299307
<Select
300-
label="Epoch"
308+
labelId={`feature-${fd.id}-epoch`}
301309
value={selectedEpoch ?? ''}
302310
onChange={(e) => setSelectedEpoch(e.target.value as string)}
303311
>

frontend/src/details/features/damages/RPDamageTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from
22
import { numFormat, numRangeFormat } from 'lib/helpers';
33
const padding = { px: 0.25, py: 0.25 };
44
export const RPDamageTable = ({ damages }) => (
5-
<TableContainer sx={{ maxHeight: 250 }}>
5+
<TableContainer sx={{ maxHeight: 250 }} tabIndex={0}>
66
<Table size="small" padding="none" stickyHeader>
77
<TableHead>
88
<TableRow>

0 commit comments

Comments
 (0)