Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TextArea): make label or aria label required #4312

Merged
merged 2 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nasty-stingrays-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ultraviolet/ui": patch
---

Fix `<TextArea />` to have either label or aria-label as required prop
15 changes: 13 additions & 2 deletions packages/ui/src/components/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,21 @@ const StyledTextArea = styled('textarea', {
}
`

type LabelProps =
| {
label: string
'aria-label'?: never
}
| {
label?: never
'aria-label': string
}

type TextAreaProps = {
id?: string
className?: string
tabIndex?: number
autoFocus?: boolean
label: string
value?: string
onChange: (newValue: string) => void
placeholder?: string
Expand Down Expand Up @@ -130,7 +139,7 @@ type TextAreaProps = {
onKeyDown?: DOMAttributes<HTMLTextAreaElement>['onKeyDown']
clearable?: boolean
labelDescription?: ReactNode
}
} & LabelProps

/**
* This component offers an extended textarea HTML
Expand Down Expand Up @@ -163,6 +172,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
onKeyDown,
clearable = false,
labelDescription,
'aria-label': ariaLabel,
},
ref,
) => {
Expand Down Expand Up @@ -232,6 +242,7 @@ export const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(
onFocus={onFocus}
onBlur={onBlur}
onKeyDown={onKeyDown}
aria-label={ariaLabel}
/>
<StyledTextAreaAbsoluteStack
direction="row"
Expand Down
Loading