From dbd96b2fc5f84a992344cf78a5fedca75c1bd9d7 Mon Sep 17 00:00:00 2001 From: Martina Bustacchini Date: Fri, 23 Feb 2024 11:52:29 +0100 Subject: [PATCH 1/4] fix: a11y for customer satisfaction section, still small problem with sr announcements --- locales/de/LC_MESSAGES/volto.po | 10 ++ locales/en/LC_MESSAGES/volto.po | 10 ++ locales/es/LC_MESSAGES/volto.po | 10 ++ locales/fr/LC_MESSAGES/volto.po | 10 ++ locales/it/LC_MESSAGES/volto.po | 10 ++ locales/volto.pot | 12 +- .../CustomerSatisfaction/FeedbackForm.jsx | 98 ++++++++--- .../Steps/Commons/Rating.jsx | 156 ++++++++---------- .../Components/_customerSatisfaction.scss | 51 +++++- 9 files changed, 249 insertions(+), 118 deletions(-) diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index 9f022e6c5..232b2c6bf 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -2000,11 +2000,21 @@ msgstr "" msgid "feedback_form_button_next" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Avanti, disabilitato +msgid "feedback_form_button_next_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: Previous msgid "feedback_form_button_prev" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Indietro, disabilitato +msgid "feedback_form_button_prev_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: No msgid "feedback_form_no" diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index 2c307c640..badeb98f5 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -1985,11 +1985,21 @@ msgstr "" msgid "feedback_form_button_next" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Avanti, disabilitato +msgid "feedback_form_button_next_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: Previous msgid "feedback_form_button_prev" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Indietro, disabilitato +msgid "feedback_form_button_prev_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: No msgid "feedback_form_no" diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index 202cc5bba..7b30ef5fc 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -1994,11 +1994,21 @@ msgstr "" msgid "feedback_form_button_next" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Avanti, disabilitato +msgid "feedback_form_button_next_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: Previous msgid "feedback_form_button_prev" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Indietro, disabilitato +msgid "feedback_form_button_prev_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: No msgid "feedback_form_no" diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index 75c8e3e16..50fad7919 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -2002,11 +2002,21 @@ msgstr "" msgid "feedback_form_button_next" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Avanti, disabilitato +msgid "feedback_form_button_next_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: Previous msgid "feedback_form_button_prev" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Indietro, disabilitato +msgid "feedback_form_button_prev_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: No msgid "feedback_form_no" diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index af6eeb3aa..052acf174 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -1985,11 +1985,21 @@ msgstr "Le indicazioni erano complete" msgid "feedback_form_button_next" msgstr "Avanti" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Avanti, disabilitato +msgid "feedback_form_button_next_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: Previous msgid "feedback_form_button_prev" msgstr "Indietro" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Indietro, disabilitato +msgid "feedback_form_button_prev_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: No msgid "feedback_form_no" diff --git a/locales/volto.pot b/locales/volto.pot index 99d704502..f1cb0154a 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2024-02-08T09:29:49.246Z\n" +"POT-Creation-Date: 2024-02-23T10:52:47.498Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -1987,11 +1987,21 @@ msgstr "" msgid "feedback_form_button_next" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Avanti, disabilitato +msgid "feedback_form_button_next_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: Previous msgid "feedback_form_button_prev" msgstr "" +#: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm +# defaultMessage: Indietro, disabilitato +msgid "feedback_form_button_prev_disabled" +msgstr "" + #: components/ItaliaTheme/CustomerSatisfaction/FeedbackForm # defaultMessage: No msgid "feedback_form_no" diff --git a/src/components/ItaliaTheme/CustomerSatisfaction/FeedbackForm.jsx b/src/components/ItaliaTheme/CustomerSatisfaction/FeedbackForm.jsx index d169e74e2..106f277ce 100644 --- a/src/components/ItaliaTheme/CustomerSatisfaction/FeedbackForm.jsx +++ b/src/components/ItaliaTheme/CustomerSatisfaction/FeedbackForm.jsx @@ -24,7 +24,7 @@ import { import cx from 'classnames'; import AnswersStep from './Steps/AnswersStep'; import CommentsStep from './Steps/CommentsStep'; -import Rating from './Steps/Commons/Rating'; +import RTRating from './Steps/Commons/Rating'; import { PropTypes } from 'prop-types'; const messages = defineMessages({ @@ -61,10 +61,18 @@ const messages = defineMessages({ id: 'feedback_form_button_next', defaultMessage: 'Next', }, + next_disabled: { + id: 'feedback_form_button_next_disabled', + defaultMessage: 'Avanti, disabilitato', + }, prev: { id: 'feedback_form_button_prev', defaultMessage: 'Previous', }, + prev_disabled: { + id: 'feedback_form_button_prev_disabled', + defaultMessage: 'Indietro, disabilitato', + }, feedback_sent: { id: 'feedback_sent', defaultMessage: 'Your feedback was sent!', @@ -149,12 +157,15 @@ const FeedbackForm = ({ contentType, pathname }) => { [field]: value, }); }; - const getFormFieldValue = (field) => formData?.[field] ?? undefined; - const nextStep = () => setStep(step + 1); + const nextStep = () => { + if (!invalidForm) setStep(step + 1); + }; - const prevStep = () => setStep(step - 1); + const prevStep = () => { + if (!invalidForm && step !== 0) setStep(step - 1); + }; useEffect(() => { setValidToken(null); @@ -193,6 +204,7 @@ const FeedbackForm = ({ contentType, pathname }) => { }; const sendFormData = () => { + if (invalidForm) return; setStep(2); const data = { ...formData, @@ -218,7 +230,7 @@ const FeedbackForm = ({ contentType, pathname }) => { -
+
{ : intl.formatMessage(messages.title)}
- threshold @@ -296,41 +324,63 @@ const FeedbackForm = ({ contentType, pathname }) => { className={cx( 'form-step-actions d-flex flex-nowrap w100 justify-content-center button-shadow', { - 'pt-4': satisfaction !== null, + 'pt-4': satisfaction, }, )} - aria-hidden={satisfaction === null} + aria-hidden={!satisfaction} > + {/* Bug bottoni del kit. Disabled e' settato anche se compare la prop aria-disabled, + quando lo scopo sarebbe continuare a poter usufruire dei focus anche in screen reader */} + {step !== numberOfSteps - 1 && ( )} {step === numberOfSteps - 1 && ( + {step !== numberOfSteps - 1 && ( - + )} {step === numberOfSteps - 1 && ( - + {intl.formatMessage(messages.submit)} + )}
@@ -409,7 +401,7 @@ const FeedbackForm = ({ contentType, pathname }) => { -
+ ); }; diff --git a/src/components/ItaliaTheme/CustomerSatisfaction/Steps/AnswersStep.jsx b/src/components/ItaliaTheme/CustomerSatisfaction/Steps/AnswersStep.jsx index a3c737172..bd37d7b9c 100644 --- a/src/components/ItaliaTheme/CustomerSatisfaction/Steps/AnswersStep.jsx +++ b/src/components/ItaliaTheme/CustomerSatisfaction/Steps/AnswersStep.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect, useMemo } from 'react'; import { usePrevious } from '@plone/volto/helpers'; -import { Form, FormGroup, Input, Label } from 'design-react-kit'; +import { Form, FormGroup, Label } from 'design-react-kit'; import { defineMessages } from 'react-intl'; import { FormHeader, @@ -76,6 +76,9 @@ const AnswersStep = ({ step={step + 1} totalSteps={totalSteps} className={'answers-header'} + hidden={ + userFeedback === null || userFeedback < threshold || step !== 0 + } />
@@ -85,14 +88,13 @@ const AnswersStep = ({ key={'positive-' + s} className="border-bottom border-light mb-4" > -