fix(chat): replace Android keyboard workaround

This commit is contained in:
2026-07-16 13:18:26 +08:00
parent 1c8a6afce1
commit 5934d48034
17 changed files with 621 additions and 532 deletions
+8 -4
View File
@@ -2,9 +2,9 @@
import { useRef, useState } from "react";
import { useChatDispatch } from "@/stores/chat/chat-context";
import { useKeyboardHeight } from "@/hooks";
import { Logger } from "@/utils/logger";
import { useChatKeyboardAvoidance } from "../hooks/use-chat-keyboard-avoidance";
import { ChatInputTextField } from "./chat-input-text-field";
import { ChatSendButton } from "./chat-send-button";
import styles from "./chat-input-bar.module.css";
@@ -20,13 +20,14 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) {
const dispatch = useChatDispatch();
const [input, setInput] = useState("");
const [isFocused, setIsFocused] = useState(false);
const barRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const lastPointerSendAtRef = useRef(0);
const hasContent = input.trim().length > 0;
useKeyboardHeight({
targetRef: textareaRef,
useChatKeyboardAvoidance({
containerRef: barRef,
active: isFocused,
});
@@ -68,7 +69,10 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) {
};
return (
<div className={`${styles.bar} ${isFocused ? styles.barFocused : ""}`}>
<div
ref={barRef}
className={`${styles.bar} ${isFocused ? styles.barFocused : ""}`}
>
<div className={`${styles.row} ${isFocused ? styles.rowFocused : ""}`}>
<ChatInputTextField
ref={textareaRef}