Skip to content

Commit

Permalink
rename ref to inputRef to avoid breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
steppy452 committed Aug 11, 2024
1 parent b3974e5 commit 08b7a34
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/form/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,22 @@ export const Textarea = forwardRef<TextAreaRef, TextareaProps>(
theme: customTheme,
...rest
},
ref
inputRef
) => {
const containerRef = useRef<HTMLDivElement | null>(null);
const inputRef = useRef<HTMLTextAreaElement | null>(null);
const textareaRef = useRef<HTMLTextAreaElement | null>(null);

useImperativeHandle(ref, () => ({
inputRef,
useImperativeHandle(inputRef, () => ({
textareaRef,
containerRef,
blur: () => inputRef.current?.blur(),
focus: () => inputRef.current?.focus()
blur: () => textareaRef.current?.blur(),
focus: () => textareaRef.current?.focus()
}));

useLayoutEffect(() => {
if (autoFocus) {
// Small timeout for page loading
requestAnimationFrame(() => inputRef.current?.focus());
requestAnimationFrame(() => textareaRef.current?.focus());
}
}, [autoFocus]);

Expand All @@ -105,7 +105,7 @@ export const Textarea = forwardRef<TextAreaRef, TextareaProps>(
ref={containerRef}
>
<TextareaAutosize
ref={inputRef}
ref={textareaRef}
className={twMerge(
theme.input,
fullWidth && theme.fullWidth,
Expand Down

0 comments on commit 08b7a34

Please sign in to comment.