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): Spread rest props to the native textarea tag #2442

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
16 changes: 2 additions & 14 deletions packages/core/src/components/TextArea/TextArea.tsx
ziperfal marked this conversation as resolved.
Show resolved Hide resolved
ziperfal marked this conversation as resolved.
Show resolved Hide resolved
ziperfal marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ const TextArea = forwardRef(
className,
"data-testid": dataTestId,
id,
name,
disabled,
readOnly,
value,
onChange,
onBlur,
"aria-label": ariaLabel,
required,
maxLength,
resize = true,
placeholder
...rest
YossiSaadi marked this conversation as resolved.
Show resolved Hide resolved
}: TextAreaProps,
ref: React.ForwardedRef<HTMLTextAreaElement>
) => {
Expand All @@ -60,22 +54,16 @@ const TextArea = forwardRef(
</label>
)}
<textarea
{...rest}
id={id}
name={name}
ref={ref}
disabled={disabled}
readOnly={readOnly}
required={required}
rows={numRows}
className={cx(styles.textArea, [styles[size]], { [styles.resize]: resize })}
value={value}
onChange={onChange}
onBlur={onBlur}
aria-invalid={error}
aria-label={ariaLabel}
aria-describedby={helpTextId ?? undefined}
placeholder={placeholder}
maxLength={maxLength}
/>
{helpText && (
<Text className={cx(styles.helpText)} color={Text.colors.INHERIT} id={helpTextId}>
Expand Down
18 changes: 1 addition & 17 deletions packages/core/src/components/TextArea/TextArea.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TextareaHTMLAttributes } from "react";
import { VibeComponentProps } from "../../types";

export type TextAreaSize = "small" | "large";
type TextAreaNativeInputProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "role">;
type TextAreaNativeInputProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, "role" | "aria-describedby" | "aria-invalid">;

export interface TextAreaProps extends TextAreaNativeInputProps, VibeComponentProps {
/**
Expand All @@ -23,22 +23,10 @@ export interface TextAreaProps extends TextAreaNativeInputProps, VibeComponentPr
* the visual styling to convey error.
*/
error?: boolean;
/**
* The number of rows in the textarea. Defaults according to the size prop.
*/
rows?: number;
/**
* Label text associated with the textarea element.
*/
label?: string;
/**
* If true, the textarea becomes non-interactive
*/
disabled?: boolean;
/**
* If true, the textarea is read-only and cannot be modified by the user
*/
readOnly?: boolean;
/**
* Function to call on textarea value change.
*/
Expand All @@ -51,10 +39,6 @@ export interface TextAreaProps extends TextAreaNativeInputProps, VibeComponentPr
* Accessibility label for the textarea element.
*/
"aria-label"?: React.AriaAttributes["aria-label"];
/**
* If true, the textarea is required and must be filled out by the user.
*/
required?: boolean;
/**
* If true, the textarea can be resized vertically by the user.
*/
Expand Down
Loading