Skip to content

Commit

Permalink
refactor(a11y): Textareas use id instead of name for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
DiggidyDev committed Mar 25, 2024
1 parent 92cfd86 commit d41c9be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ export function TextArea({
...props
}: TextAreaProps) {
name = name ?? label.toLowerCase();
name = name.replaceAll(" ", "-");

return (
<div data-cy={testId} className="flex w-full flex-col text-center">
<Label text={label} htmlFor={name} />
<StyledTextArea
name={name}
id={name}
onChange={(e: ChangeEvent<HTMLTextAreaElement>) =>
setValue?.(e.target.value)
}
Expand All @@ -49,7 +50,7 @@ TextArea.Loading = ({ label = "Loading...", ...props }: LoadingProps) => (
<StyledTextArea
className="duration-1000 animate-pulse disabled:bg-gray-300"
disabled
name="loading"
id="loading"
{...props}
/>
</div>
Expand Down

0 comments on commit d41c9be

Please sign in to comment.