Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(composer): handle Android compatibility mouse-down (#6789)

Tim216c96eb8fa2
diff --git a/packages/ui/components/common/submit-button.tsx b/packages/ui/components/common/submit-button.tsx
index bc3cff06ae..63494d4450 100644
--- a/packages/ui/components/common/submit-button.tsx
+++ b/packages/ui/components/common/submit-button.tsx
@@ -1,6 +1,6 @@
"use client";
-import type { PointerEvent, ReactNode } from "react";
+import type { ReactNode, SyntheticEvent } from "react";
import { ArrowUp, Loader2, Square } from "lucide-react";
import { Button } from "@multica/ui/components/ui/button";
import {
@@ -40,7 +40,7 @@ interface SubmitButtonProps {
}
/** Keep the composer focused so Send and Stop do not dismiss Android's keyboard. */
-function keepFocusInComposer(event: PointerEvent<HTMLButtonElement>) {
+function keepFocusInComposer(event: SyntheticEvent<HTMLButtonElement>) {
event.preventDefault();
}
@@ -62,6 +62,7 @@ function SubmitButton({
size="icon-sm"
className="rounded-full"
onPointerDown={keepFocusInComposer}
+ onMouseDown={keepFocusInComposer}
onClick={onStop}
aria-label={stopAriaLabel}
>
@@ -84,6 +85,7 @@ function SubmitButton({
aria-disabled={busy || undefined}
aria-busy={loading || busy || undefined}
onPointerDown={keepFocusInComposer}
+ onMouseDown={keepFocusInComposer}
onClick={onClick}
aria-label={ariaLabel}
>
diff --git a/packages/views/chat/components/chat-input.test.tsx b/packages/views/chat/components/chat-input.test.tsx
index c2288e9109..19ea4db91c 100644
--- a/packages/views/chat/components/chat-input.test.tsx
+++ b/packages/views/chat/components/chat-input.test.tsx
@@ -1433,6 +1433,13 @@ describe("ChatInput send keeps composer focus", () => {
expect(fireEvent.pointerDown(sendButton)).toBe(false);
});
+ it("cancels the send button's compatibility mouse-down on Android", async () => {
+ renderInput();
+ const sendButton = await readySendButton();
+
+ expect(fireEvent.mouseDown(sendButton)).toBe(false);
+ });
+
it("still submits on tap — cancelling pointer-down suppresses focus, not activation", async () => {
const onSend = vi.fn<ChatInputOnSend>((_content, _ids, commitInput) => {
commitInput();
@@ -1454,6 +1461,12 @@ describe("ChatInput send keeps composer focus", () => {
expect(fireEvent.pointerDown(screen.getByRole("button", { name: "Stop" }))).toBe(false);
});
+ it("cancels the stop button's compatibility mouse-down on Android", () => {
+ renderInput({ isRunning: true, onStop: vi.fn() });
+
+ expect(fireEvent.mouseDown(screen.getByRole("button", { name: "Stop" }))).toBe(false);
+ });
+
it("still stops on tap", () => {
const onStop = vi.fn();
renderInput({ isRunning: true, onStop });