From 2456ba97ec944e8f87d3f86e453f1b7b562041d0 Mon Sep 17 00:00:00 2001 From: Ian Jones Date: Thu, 5 Sep 2024 14:55:11 +0100 Subject: [PATCH] fix(a11y): Fieldset and legend for list/map date input --- .../Schema/InputFields/DateFieldInput.tsx | 32 +++++++++++-------- editor.planx.uk/src/ui/shared/DateInput.tsx | 4 +-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/DateFieldInput.tsx b/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/DateFieldInput.tsx index a11f7ee4df..298ecd1ef2 100644 --- a/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/DateFieldInput.tsx +++ b/editor.planx.uk/src/@planx/components/shared/Schema/InputFields/DateFieldInput.tsx @@ -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 "."; @@ -13,21 +14,24 @@ export const DateFieldInput: React.FC> = (props) => { const { id, errorMessage, name, value } = getFieldProps(props); return ( - + + + + {data.title} + + {data.description && ( )} - - { - formik.setFieldValue(name, paddedDate(newDate, eventType)); - }} - error={errorMessage} - id={id} - /> - - + { + formik.setFieldValue(name, paddedDate(newDate, eventType)); + }} + error={errorMessage} + id={id} + /> + ); }; diff --git a/editor.planx.uk/src/ui/shared/DateInput.tsx b/editor.planx.uk/src/ui/shared/DateInput.tsx index 115bfab956..caa063ea63 100644 --- a/editor.planx.uk/src/ui/shared/DateInput.tsx +++ b/editor.planx.uk/src/ui/shared/DateInput.tsx @@ -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. "& > * + *": { @@ -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;