mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-27 01:16:23 +02:00
add auto-focus feature to chat input and prompt textarea
This commit is contained in:
parent
2d5a5fc8f7
commit
1b76d5a486
2 changed files with 16 additions and 1 deletions
|
|
@ -322,6 +322,7 @@ function ChatInputInner({
|
|||
placeholder="Type your message..."
|
||||
disabled={isProcessing}
|
||||
onKeyDown={handleKeyDown}
|
||||
autoFocus
|
||||
className="min-h-6 py-0 border-0 shadow-none focus-visible:ring-0 rounded-none"
|
||||
/>
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -904,13 +904,16 @@ export const PromptInputBody = ({
|
|||
|
||||
export type PromptInputTextareaProps = ComponentProps<
|
||||
typeof InputGroupTextarea
|
||||
>;
|
||||
> & {
|
||||
autoFocus?: boolean;
|
||||
};
|
||||
|
||||
export const PromptInputTextarea = ({
|
||||
onChange,
|
||||
className,
|
||||
placeholder = "What would you like to know?",
|
||||
onKeyDown: externalOnKeyDown,
|
||||
autoFocus = false,
|
||||
...props
|
||||
}: PromptInputTextareaProps) => {
|
||||
const controller = useOptionalPromptInputController();
|
||||
|
|
@ -920,6 +923,17 @@ export const PromptInputTextarea = ({
|
|||
const [isComposing, setIsComposing] = useState(false);
|
||||
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||
|
||||
// Auto-focus the textarea when requested
|
||||
useEffect(() => {
|
||||
if (autoFocus) {
|
||||
// Small delay to ensure the element is fully mounted and visible
|
||||
const timer = setTimeout(() => {
|
||||
textareaRef.current?.focus();
|
||||
}, 50);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [autoFocus]);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const highlightRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue