fix(FN-xxx): keep quick chat keyboard open after send on mobile

This commit is contained in:
gsxdsm
2026-05-01 06:51:24 -07:00
parent 72dffe4f33
commit 41e5458610
3 changed files with 20 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@runfusion/fusion": patch
---
Keep the mobile keyboard open in Quick Chat after tapping send so users can continue typing without an extra tap.

View File

@@ -1343,6 +1343,14 @@ export function QuickChatFAB({
handleAttachmentFiles(event.clipboardData?.files);
}, [handleAttachmentFiles]);
const focusComposerInput = useCallback(() => {
if (typeof window === "undefined") return;
if (window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
const input = inputRef.current;
if (!input || input.disabled) return;
input.focus({ preventScroll: true });
}, []);
const handleSendMessage = useCallback(async () => {
const trimmed = messageInput.trim();
const attachmentsToSend = pendingAttachmentsRef.current;
@@ -1364,8 +1372,10 @@ export function QuickChatFAB({
setPendingAttachments((previous) => previous.filter((attachment) => !attachmentsToSend.includes(attachment)));
} catch {
// Keep pending attachments on failure so user can retry.
} finally {
focusComposerInput();
}
}, [sendMessage, inputDisabled, messageInput]);
}, [sendMessage, inputDisabled, messageInput, focusComposerInput]);
const handleAttachmentDragEnter = useCallback((event: React.DragEvent<HTMLDivElement>) => {
event.preventDefault();
@@ -2053,6 +2063,7 @@ export function QuickChatFAB({
onTouchStart={(event) => {
if (typeof window === "undefined" || window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
event.preventDefault();
focusComposerInput();
void handleSendMessage();
}}
onClick={() => {

View File

@@ -2151,6 +2151,7 @@ describe("QuickChatFAB", () => {
expect(input).not.toBeDisabled();
});
fireEvent.focus(input);
fireEvent.change(input, { target: { value: "send from touch" } });
const sendButton = screen.getByTestId("quick-chat-send");
@@ -2159,6 +2160,8 @@ describe("QuickChatFAB", () => {
await waitFor(() => {
expect(mockStreamChatResponse).toHaveBeenCalledTimes(1);
});
expect(document.activeElement).toBe(input);
});
it("does not subscribe to keyboard tracking while panel is closed", async () => {