From cdfb9acff7c8c75cee69df6e4944d64b8d3d8b24 Mon Sep 17 00:00:00 2001 From: Anders Rognstad Date: Thu, 28 Nov 2024 13:10:31 +0100 Subject: [PATCH] Move error messages to avoid funky button --- src/components/sokperson/SokPerson.tsx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/sokperson/SokPerson.tsx b/src/components/sokperson/SokPerson.tsx index aa5725b2..8a5c55d5 100644 --- a/src/components/sokperson/SokPerson.tsx +++ b/src/components/sokperson/SokPerson.tsx @@ -4,6 +4,7 @@ import { BodyShort, Box, Button, + ErrorMessage, Heading, HStack, TextField, @@ -66,6 +67,9 @@ export default function SokPerson() { } }; + const invalidInitials = isFormError && !validInitials(nameInitials); + const invalidBirthdate = isFormError && parseBirthdate(birthdate) === null; + return ( <> @@ -81,11 +85,7 @@ export default function SokPerson() { htmlSize={10} type="text" onChange={(e) => setNameInitials(e.target.value)} - error={ - isFormError && !validInitials(nameInitials) - ? texts.validation.initials - : undefined - } + error={invalidInitials} /> setBirthdate(e.target.value)} - error={ - isFormError && parseBirthdate(birthdate) === null - ? texts.validation.birthdate - : undefined - } + error={invalidBirthdate} />