Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a11y): Fieldset and legend for list/map date input #3631

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { paddedDate } from "@planx/components/DateInput/model";
import type { DateField } from "@planx/components/shared/Schema/model";
import React from "react";
import InputLabel from "ui/public/InputLabel";
import InputLegend from "ui/editor/InputLegend";
import DateInput from "ui/shared/DateInput";

import { getFieldProps, Props } from ".";
Expand All @@ -13,21 +14,24 @@ export const DateFieldInput: React.FC<Props<DateField>> = (props) => {
const { id, errorMessage, name, value } = getFieldProps(props);

return (
<InputLabel label={data.title} htmlFor={id}>
<Box component="fieldset">
<InputLegend>
<Typography variant="body1" pb={1}>
<strong>{data.title}</strong>
</Typography>
</InputLegend>
{data.description && (
<FieldInputDescription description={data.description} />
)}
<Box sx={{ display: "flex", alignItems: "baseline" }}>
<DateInput
value={value?.toString()}
bordered
onChange={(newDate: string, eventType: string) => {
formik.setFieldValue(name, paddedDate(newDate, eventType));
}}
error={errorMessage}
id={id}
/>
</Box>
</InputLabel>
<DateInput
value={value?.toString()}
bordered
onChange={(newDate: string, eventType: string) => {
formik.setFieldValue(name, paddedDate(newDate, eventType));
}}
error={errorMessage}
id={id}
/>
</Box>
);
};
4 changes: 2 additions & 2 deletions editor.planx.uk/src/ui/shared/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const INPUT_YEAR_WIDTH = "84px";

const Root = styled(Box)(({ theme }) => ({
display: "flex",
alignItems: "bottom",
alignItems: "flex-end",
// Adds a uniform horizontal spacing between all child elements.
// The `* + *` selector makes sure the first element doesn't get this margin.
"& > * + *": {
Expand All @@ -31,7 +31,7 @@ const Root = styled(Box)(({ theme }) => ({
const Label = styled(Typography)(({ theme }) => ({
minWidth: INPUT_DATE_WIDTH,
alignSelf: "end",
marginBottom: theme.spacing(0.5),
marginBottom: theme.spacing(1),
display: "inline-block",
})) as typeof Typography;

Expand Down
Loading