Skip to content

Commit cb8ba1b

Browse files
committed
fix: form error
1 parent 75f0140 commit cb8ba1b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/Shared/Components/FormFieldWrapper/FormFieldInfo.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ const FormInfoItem = ({ id, text, icon, textClass }: FormInfoItemProps) => (
2929

3030
const FormFieldInfo = ({ error, helperText, warningText, inputId }: FormFieldInfoProps) => (
3131
<div className="flex left column dc__gap-4">
32-
{error && <FormInfoItem text={error} icon={<ICError />} textClass="cr-5" id={getFormErrorElementId(inputId)} />}
33-
{helperText && (
32+
{!!error && (
33+
<FormInfoItem text={error} icon={<ICError />} textClass="cr-5" id={getFormErrorElementId(inputId)} />
34+
)}
35+
{!!helperText && (
3436
<FormInfoItem
3537
text={helperText}
3638
icon={<ICInfoFilledOverride className="info-icon-n6" />}
3739
textClass="cn-7"
3840
id={`${inputId}-helper-text`}
3941
/>
4042
)}
41-
{warningText && (
43+
{!!warningText && (
4244
<FormInfoItem
4345
text={warningText}
4446
icon={<ICWarning className="warning-icon-y7" />}

src/Shared/Components/FormFieldWrapper/FormFieldWrapper.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const FormFieldWrapper = ({
3333
}: Required<FormFieldWrapperProps>) => {
3434
const isRowLayout = layout === 'row'
3535
const itemContainerClassName = isRowLayout ? 'dc__mxw-250 w-100 mxh-36 dc__align-self-stretch' : ''
36+
const formError = Array.isArray(error) ? error?.[0] : error
3637

3738
return (
3839
<div className={`flex left column top dc__gap-4 ${fullWidth ? 'w-100' : ''}`}>
@@ -56,11 +57,16 @@ const FormFieldWrapper = ({
5657
)}
5758
<div className="w-100 dc__position-rel">{children}</div>
5859
</div>
59-
{(error || helperText || warningText) && (
60+
{(!!formError || !!helperText || !!warningText) && (
6061
<div className="flex left dc__gap-6 w-100">
6162
{/* Added a hidden div for layout sync */}
6263
{isRowLayout && <div className={`${itemContainerClassName} dc__visibility-hidden`} />}
63-
<FormFieldInfo inputId={inputId} error={error} helperText={helperText} warningText={warningText} />
64+
<FormFieldInfo
65+
inputId={inputId}
66+
error={formError}
67+
helperText={helperText}
68+
warningText={warningText}
69+
/>
6470
</div>
6571
)}
6672
</div>

0 commit comments

Comments
 (0)