From 02d6b6e7719ef0016cde109aaa0344381affeaf1 Mon Sep 17 00:00:00 2001 From: Kar Rui Date: Wed, 21 Sep 2022 16:49:27 +0800 Subject: [PATCH] feat: read out submission confirmation for screen readers on success --- .../BuilderAndDesignContent/EndPageView.tsx | 1 + .../EditEndPageDrawer/EditEndPage.tsx | 5 ++- .../components/FormEndPage/FormEndPage.tsx | 7 +++- .../FormEndPage/FormEndPageContainer.tsx | 1 + .../FormEndPage/components/EndPageBlock.tsx | 34 ++++++++++++++++--- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/EndPageView.tsx b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/EndPageView.tsx index 2782ffecf7..7319b4b04e 100644 --- a/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/EndPageView.tsx +++ b/frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignContent/EndPageView.tsx @@ -66,6 +66,7 @@ export const EndPageView = ({ ...props }: FlexProps): JSX.Element => { w="100%" > Title - + {errors.title?.message} void @@ -34,7 +35,11 @@ export const FormEndPage = ({ w="100%" divider={} > - + {isFeedbackSubmitted ? null : ( { + const focusRef = useRef(null) + useEffect(() => { + if (focusOnMount) { + focusRef.current?.focus() + } + }, [focusOnMount]) + + const submittedAriaText = useMemo(() => { + if (formTitle) { + return `You have successfully submitted your response for ${formTitle}.` + } + return 'You have successfully submitted your response.' + }, [formTitle]) + return ( - - - {endPage.title} - + + + + {submittedAriaText} + + + {endPage.title} + + {endPage.paragraph ? (