fix(web): keep editable text stable while typing
All checks were successful
CI / test (push) Successful in 21s

This commit is contained in:
2026-03-08 13:25:28 +03:00
parent 704781e359
commit eb0852e64d

View File

@@ -37,6 +37,7 @@ export function MessageComposer() {
const pointerMoveHandlerRef = useRef<((event: globalThis.PointerEvent) => void) | null>(null);
const pointerUpHandlerRef = useRef<((event: globalThis.PointerEvent) => void) | null>(null);
const recordingStateRef = useRef<RecordingState>("idle");
const lastEditingMessageIdRef = useRef<number | null>(null);
const [isUploading, setIsUploading] = useState(false);
const [uploadProgress, setUploadProgress] = useState(0);
@@ -73,20 +74,22 @@ export function MessageComposer() {
if (text !== "") {
setText("");
}
lastEditingMessageIdRef.current = null;
return;
}
if (editingMessage) {
const editingText = editingMessage.text ?? "";
if (text !== editingText) {
setText(editingText);
if (lastEditingMessageIdRef.current !== editingMessage.id) {
setText(editingMessage.text ?? "");
}
lastEditingMessageIdRef.current = editingMessage.id;
return;
}
lastEditingMessageIdRef.current = null;
const draft = draftsByChat[activeChatId] ?? "";
if (draft !== text) {
setText(draft);
}
}, [activeChatId, draftsByChat, text, editingMessage]);
}, [activeChatId, draftsByChat, editingMessage, text]);
useEffect(() => {
return () => {