From 5c75787e74d0115c97efc417da3657344cc03621 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Mon, 7 Mar 2022 17:29:13 +0200 Subject: [PATCH 1/3] Allow using inline placeholders instead of labels --- src/components/Field.jsx | 13 +++++++++---- src/components/FormView.jsx | 2 ++ src/components/View.jsx | 2 +- src/formSchema.js | 5 +++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/Field.jsx b/src/components/Field.jsx index 978f124..e48cb5e 100644 --- a/src/components/Field.jsx +++ b/src/components/Field.jsx @@ -44,6 +44,7 @@ const Field = ({ disabled = false, formHasErrors = false, id, + labelsAsPlaceholders, }) => { const intl = useIntl(); @@ -57,13 +58,15 @@ const Field = ({ )} @@ -71,7 +74,8 @@ const Field = ({ {}} getVocabularyTokenTitle={() => {}} @@ -183,7 +187,8 @@ const Field = ({ 0} + labelsAsPlaceholders={data.labelsAsPlaceholders} /> @@ -159,6 +160,7 @@ const FormView = ({ } valid={isValidField(name)} formHasErrors={formErrors?.length > 0} + labelsAsPlaceholders={data.labelsAsPlaceholders} /> diff --git a/src/components/View.jsx b/src/components/View.jsx index d57a956..62a4467 100644 --- a/src/components/View.jsx +++ b/src/components/View.jsx @@ -148,7 +148,7 @@ const View = ({ data, id, path }) => { path, id, Object.keys(formData).map((name) => ({ - ...formData[name] + ...formData[name], })), attachments, ), diff --git a/src/formSchema.js b/src/formSchema.js index d8e738f..71c763a 100644 --- a/src/formSchema.js +++ b/src/formSchema.js @@ -74,6 +74,7 @@ export default () => { ...invisibleHCaptcha, 'store', 'send', + 'labelsAsPlaceholders', ], }, ], @@ -111,6 +112,10 @@ export default () => { type: 'boolean', title: intl.formatMessage(messages.send), }, + labelsAsPlaceholders: { + type: 'boolean', + title: 'Use labels as placeholders', + }, }, required: ['default_to', 'default_from', 'default_subject'], }; From 28513a43dee542a7f21eb855795c793076b08a12 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Sat, 13 Aug 2022 14:58:26 +0300 Subject: [PATCH 2/3] Use state to force the update of disabled flag on captcha validation --- src/components/FormView.jsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/FormView.jsx b/src/components/FormView.jsx index 3725b8d..1455900 100644 --- a/src/components/FormView.jsx +++ b/src/components/FormView.jsx @@ -55,13 +55,10 @@ const FormView = ({ ? 'GoogleReCaptcha' : null; - let validToken = useRef(''); - const onVerifyCaptcha = useCallback( - (token) => { - validToken.current = token; - }, - [validToken], - ); + let [validToken, setValidToken] = React.useState(); + const onVerifyCaptcha = useCallback((token) => { + setValidToken(token); + }, []); const isValidField = (field) => { return formErrors?.indexOf(field) < 0; @@ -195,9 +192,7 @@ const FormView = ({