diff --git a/src/app/features/room/RoomInput.test.tsx b/src/app/features/room/RoomInput.test.tsx
index 10186cc3b..f61c9674c 100644
--- a/src/app/features/room/RoomInput.test.tsx
+++ b/src/app/features/room/RoomInput.test.tsx
@@ -781,6 +781,51 @@ describe('RoomInput submit regressions', () => {
);
});
+ it('sends on touch pointerup when the tap never produces a click', async () => {
+ render();
+ fireEvent.click(screen.getByRole('button', { name: 'Compose text' }));
+
+ fireEvent.pointerDown(sendButton(), { pointerType: 'touch' });
+ fireEvent.pointerUp(sendButton(), { pointerType: 'touch' });
+
+ await waitFor(() => expect(testState.matrix.sendMessage).toHaveBeenCalledOnce());
+ });
+
+ it('sends once when a touch tap produces both a pointerup and a click', async () => {
+ render();
+ fireEvent.click(screen.getByRole('button', { name: 'Compose text' }));
+
+ const submit = sendButton();
+ fireEvent.pointerDown(submit, { pointerType: 'touch' });
+ fireEvent.pointerUp(submit, { pointerType: 'touch' });
+ fireEvent.click(submit);
+
+ await waitFor(() => expect(testState.matrix.sendMessage).toHaveBeenCalledOnce());
+ });
+
+ it('cancels a touch send released outside the button', () => {
+ render();
+ fireEvent.click(screen.getByRole('button', { name: 'Compose text' }));
+
+ fireEvent.pointerDown(sendButton(), { pointerType: 'touch' });
+ fireEvent.pointerUp(sendButton(), { pointerType: 'touch', clientX: 200, clientY: 200 });
+
+ expect(testState.matrix.sendMessage).not.toHaveBeenCalled();
+ });
+
+ it('leaves mouse taps on the click path', async () => {
+ render();
+ fireEvent.click(screen.getByRole('button', { name: 'Compose text' }));
+
+ const submit = sendButton();
+ fireEvent.pointerDown(submit, { pointerType: 'mouse' });
+ fireEvent.pointerUp(submit, { pointerType: 'mouse' });
+ expect(testState.matrix.sendMessage).not.toHaveBeenCalled();
+
+ fireEvent.click(submit);
+ await waitFor(() => expect(testState.matrix.sendMessage).toHaveBeenCalledOnce());
+ });
+
it('waits for an attachment transaction instead of sending text independently', async () => {
const upload = deferred<{ content_uri: string }>();
const file = new File(['attachment'], 'attachment.txt', { type: 'text/plain' });
diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx
index d3436d030..7367b9d42 100644
--- a/src/app/features/room/RoomInput.tsx
+++ b/src/app/features/room/RoomInput.tsx
@@ -1,4 +1,10 @@
-import type { KeyboardEventHandler, MouseEvent, ReactElement, RefObject } from 'react';
+import type {
+ KeyboardEventHandler,
+ MouseEvent,
+ PointerEvent,
+ ReactElement,
+ RefObject,
+} from 'react';
import {
forwardRef,
Fragment,
@@ -408,6 +414,7 @@ export const RoomInput = forwardRef(
const uploadBoardHandlers = useRef();
const longPressTimer = useRef | null>(null);
const isLongPress = useRef(false);
+ const sentOnPointerUpRef = useRef(false);
const suppressBlurRefocusRef = useRef(false);
const editorRafIdsRef = useRef(new Set());
const scheduleEditorRaf = useCallback((callback: () => void) => {
@@ -2518,6 +2525,7 @@ export const RoomInput = forwardRef(
isLongPress.current = false;
return;
}
+ if (sentOnPointerUpRef.current) return;
submit();
return;
}
@@ -2530,6 +2538,7 @@ export const RoomInput = forwardRef(
if (hasContent) e.preventDefault();
}}
onPointerDown={() => {
+ sentOnPointerUpRef.current = false;
if (showAudioRecorder) return;
if (hasContent) {
isLongPress.current = false;
@@ -2577,11 +2586,26 @@ export const RoomInput = forwardRef(
window.addEventListener('pointerup', onUp);
window.addEventListener('pointercancel', discardRecording);
}}
- onPointerUp={() => {
+ onPointerUp={(evt: PointerEvent) => {
if (longPressTimer.current !== null) {
clearTimeout(longPressTimer.current);
longPressTimer.current = null;
}
+ // iOS drops the synthesized click when the page mutates during a tap.
+ if (evt.pointerType === 'mouse') return;
+ if (showAudioRecorder || !hasContent || isLongPress.current) return;
+ // Touch implicitly captures the pointer, so a release off the button lands here too.
+ const rect = evt.currentTarget.getBoundingClientRect();
+ if (
+ evt.clientX < rect.left ||
+ evt.clientX > rect.right ||
+ evt.clientY < rect.top ||
+ evt.clientY > rect.bottom
+ ) {
+ return;
+ }
+ sentOnPointerUpRef.current = true;
+ submit();
}}
onPointerCancel={() => {
if (longPressTimer.current !== null) {