From 9f74e897f9ee60ae121b05e1442ff356aff9468a Mon Sep 17 00:00:00 2001 From: ismay Date: Wed, 22 Apr 2020 17:11:13 +0200 Subject: [PATCH] fix: display submit errors --- .../src/shared/helpers/getValidationText.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/forms/src/shared/helpers/getValidationText.js b/packages/forms/src/shared/helpers/getValidationText.js index 29b80d2f36..e617a51237 100644 --- a/packages/forms/src/shared/helpers/getValidationText.js +++ b/packages/forms/src/shared/helpers/getValidationText.js @@ -1,6 +1,21 @@ import { hasError } from './hasError.js' -const getValidationText = (meta, validationText, error) => - validationText || (hasError(meta, error) && meta.error) || '' +const getValidationText = (meta, validationText, error) => { + if (validationText) { + return validationText + } + + if (hasError(meta, error)) { + if (meta.error) { + return meta.error + } + + if (meta.submitError) { + return meta.submitError + } + } + + return '' +} export { getValidationText }