Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
fix: input must be direct child of Form Control
Browse files Browse the repository at this point in the history
otherwise the error messages won't display. divs moved to surround the form control elem
  • Loading branch information
hetd54 committed Aug 1, 2024
1 parent d51f515 commit 784a807
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
return (
<Form.Field name={name} className="flex flex-col gap-2">
<Form.Label>{label}</Form.Label>
<Form.Control asChild>
<div className="flex items-center gap-2 bg-white rounded-full shadow-inner min-w-60 w-max py-3 px-5 focus-within:shadow-inner-focus">
<span className="text-neutral-300 w-5 h-5">{icon}</span>
<div className="flex items-center gap-2 bg-white rounded-full shadow-inner min-w-60 w-max py-3 px-5 focus-within:shadow-inner-focus">
{icon && <span className="text-neutral-300 w-5 h-5">{icon}</span>}

<Form.Control asChild>
<input {...delegated} ref={ref} />
</div>
</Form.Control>
<Form.Message className="text-primary-300" match="valueMissing">
</Form.Control>
</div>
<Form.Message className="px-2 text-primary-300" match="valueMissing">
Please enter your {label}
</Form.Message>
{match !== undefined && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
onChange={(e) => setCharacterCount(e.target.value.length)}
/>
</Form.Control>
<Form.Message className="text-primary-300" match="valueMissing">
<Form.Message className="text-primary-300 px-2" match="valueMissing">
Please enter your {label}
</Form.Message>
</Form.Field>
Expand Down

0 comments on commit 784a807

Please sign in to comment.