fix(FN-xxx): keep quick chat keyboard open after send on mobile
This commit is contained in:
5
.changeset/keep-quick-chat-keyboard-open-mobile.md
Normal file
5
.changeset/keep-quick-chat-keyboard-open-mobile.md
Normal 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.
|
||||||
@@ -1343,6 +1343,14 @@ export function QuickChatFAB({
|
|||||||
handleAttachmentFiles(event.clipboardData?.files);
|
handleAttachmentFiles(event.clipboardData?.files);
|
||||||
}, [handleAttachmentFiles]);
|
}, [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 handleSendMessage = useCallback(async () => {
|
||||||
const trimmed = messageInput.trim();
|
const trimmed = messageInput.trim();
|
||||||
const attachmentsToSend = pendingAttachmentsRef.current;
|
const attachmentsToSend = pendingAttachmentsRef.current;
|
||||||
@@ -1364,8 +1372,10 @@ export function QuickChatFAB({
|
|||||||
setPendingAttachments((previous) => previous.filter((attachment) => !attachmentsToSend.includes(attachment)));
|
setPendingAttachments((previous) => previous.filter((attachment) => !attachmentsToSend.includes(attachment)));
|
||||||
} catch {
|
} catch {
|
||||||
// Keep pending attachments on failure so user can retry.
|
// 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>) => {
|
const handleAttachmentDragEnter = useCallback((event: React.DragEvent<HTMLDivElement>) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -2053,6 +2063,7 @@ export function QuickChatFAB({
|
|||||||
onTouchStart={(event) => {
|
onTouchStart={(event) => {
|
||||||
if (typeof window === "undefined" || window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
|
if (typeof window === "undefined" || window.innerWidth > QUICK_CHAT_DESKTOP_BREAKPOINT) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
focusComposerInput();
|
||||||
void handleSendMessage();
|
void handleSendMessage();
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -2151,6 +2151,7 @@ describe("QuickChatFAB", () => {
|
|||||||
expect(input).not.toBeDisabled();
|
expect(input).not.toBeDisabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fireEvent.focus(input);
|
||||||
fireEvent.change(input, { target: { value: "send from touch" } });
|
fireEvent.change(input, { target: { value: "send from touch" } });
|
||||||
|
|
||||||
const sendButton = screen.getByTestId("quick-chat-send");
|
const sendButton = screen.getByTestId("quick-chat-send");
|
||||||
@@ -2159,6 +2160,8 @@ describe("QuickChatFAB", () => {
|
|||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(mockStreamChatResponse).toHaveBeenCalledTimes(1);
|
expect(mockStreamChatResponse).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(document.activeElement).toBe(input);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not subscribe to keyboard tracking while panel is closed", async () => {
|
it("does not subscribe to keyboard tracking while panel is closed", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user