Skip to content

Commit

Permalink
fix: ComposerInput autoFocus should not scroll the page, enable autoS…
Browse files Browse the repository at this point in the history
…croll by default in template (#318)
  • Loading branch information
Yonom authored Jun 26, 2024
1 parent 9c45bc9 commit 31989eb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/react/src/primitives/composer/ComposerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const ComposerInput = forwardRef<
const textarea = textareaRef.current;
if (!textarea || !autoFocusEnabled) return;

textarea.focus();
textarea.focus({ preventScroll: true });
textarea.setSelectionRange(
textareaRef.current.value.length,
textareaRef.current.value.length,
Expand All @@ -88,7 +88,6 @@ export const ComposerInput = forwardRef<
value={value}
{...rest}
ref={ref}
autoFocus={autoFocus}
disabled={disabled}
onChange={composeEventHandlers(onChange, (e) => {
const composerState = useComposer.getState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ const Composer: FC = () => {
return (
<ComposerPrimitive.Root className="flex w-[calc(100%-32px)] max-w-[42rem] items-end rounded-lg border p-0.5 transition-shadow focus-within:shadow-sm">
<ComposerPrimitive.Input
autoFocus
placeholder="Write a message..."
className="placeholder:text-foreground/50 h-12 max-h-40 flex-grow resize-none bg-transparent p-3.5 text-sm outline-none"
/>
Expand Down

0 comments on commit 31989eb

Please sign in to comment.