Compare commits

...
Author SHA1 Message Date
Lotus CIandClaude Opus 5.5 f920fd82fb fix(touch): harden long-press for iOS (#199)
CI / Build & Quality Checks (pull_request) Successful in 2m57s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 8s
CI / Playwright smoke (e2e) (pull_request) Successful in 18m1s
Long-press opens the message action sheet (#166), but on iOS the system
takes a long-press for itself: the link/image callout or the text-selection
loupe races the 450 ms press. Message rows on touch screens now carry
data-touch-actions (no -webkit-touch-callout), and the pressed row carries
data-pressing from touch-down until the finger lifts, which turns text
selection off for that moment only. Copy Text stays in the sheet.

Refs #199

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
2026-10-20 20:13:04 -04:00
jared ccbafdb147 Merge pull request 'chore(deps): element-call lotus.28, soundboard in voice channels with a call policy (EC #47)' (#438) from chore/soundboard-mic-mix into lotus
CI / Build & Quality Checks (push) Successful in 4m12s
CI / Docker image build & smoke test (push) Skipped
CI / Secret scan (gitleaks) (push) Successful in 15s
CI / Trigger Desktop Build (push) Successful in 4s
CI / Playwright smoke (e2e) (push) Successful in 24m18s
CI / Build & Quality Checks (pull_request) Canceled after 0s
CI / Trigger Desktop Build (pull_request) Canceled after 0s
CI / Secret scan (gitleaks) (pull_request) Canceled after 0s
CI / Docker image build & smoke test (pull_request) Canceled after 0s
CI / Playwright smoke (e2e) (pull_request) Canceled after 0s
2026-10-20 00:04:51 -04:00
2 changed files with 40 additions and 5 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
import { style } from '@vanilla-extract/css';
import { globalStyle, style } from '@vanilla-extract/css';
import { DefaultReset, FocusOutline, color, config, toRem } from 'folds';
export const MessageBase = style({
@@ -77,3 +77,14 @@ export const ReactionsMore = style([
export const ReactionsTooltipText = style({
wordBreak: 'break-word',
});
// [Gitea #199] Long-press opens the message action sheet on touch screens. On
// iOS a long-press otherwise belongs to the system: a link/image callout, or
// the text-selection loupe, both of which race (and win against) the 450 ms
// press. No callout on message rows, and no selection while a finger is
// down; copying text is in the sheet.
globalStyle('[data-touch-actions]', { WebkitTouchCallout: 'none' });
globalStyle('[data-touch-actions][data-pressing], [data-touch-actions][data-pressing] *', {
userSelect: 'none',
WebkitUserSelect: 'none',
});
+28 -4
View File
@@ -17,22 +17,37 @@ export function useLongPress(onLongPress: (x: number, y: number) => void) {
const timer = useRef<number | undefined>(undefined);
const start = useRef<{ x: number; y: number } | null>(null);
const fired = useRef(false);
// [Gitea #199] The element being pressed carries `data-pressing` (set on the
// DOM directly, no re-render) so iOS can't start a text selection under
// the finger; see `[data-touch-actions]` in room/message/styles.css.ts.
const pressed = useRef<HTMLElement | null>(null);
const clear = useCallback(() => {
const stopTimer = useCallback(() => {
if (timer.current !== undefined) window.clearTimeout(timer.current);
timer.current = undefined;
start.current = null;
}, []);
// The finger is up (or the gesture was cancelled): only now drop
// `data-pressing`, so the system selection can't start under a finger that
// is still down after the sheet opened.
const clear = useCallback(() => {
stopTimer();
pressed.current?.removeAttribute('data-pressing');
pressed.current = null;
}, [stopTimer]);
const onTouchStart = useCallback(
(evt: React.TouchEvent) => {
if (!coarse || evt.touches.length !== 1) return;
const t = evt.touches[0];
start.current = { x: t.clientX, y: t.clientY };
fired.current = false;
pressed.current = evt.currentTarget as HTMLElement;
pressed.current.setAttribute('data-pressing', '');
timer.current = window.setTimeout(() => {
const s = start.current;
clear();
stopTimer();
if (!s) return;
fired.current = true;
window.setTimeout(() => {
@@ -41,7 +56,7 @@ export function useLongPress(onLongPress: (x: number, y: number) => void) {
onLongPress(s.x, s.y);
}, LONG_PRESS_MS);
},
[coarse, clear, onLongPress],
[coarse, stopTimer, onLongPress],
);
const onTouchMove = useCallback(
@@ -72,7 +87,16 @@ export function useLongPress(onLongPress: (x: number, y: number) => void) {
return {
coarse,
handlers: coarse ? { onTouchStart, onTouchMove, onTouchEnd, onTouchCancel: clear } : {},
handlers: coarse
? {
// [Gitea #199] Marks the element for the iOS hardening CSS.
'data-touch-actions': '',
onTouchStart,
onTouchMove,
onTouchEnd,
onTouchCancel: clear,
}
: {},
/** True for ~1 s after a long-press fired (drop the Android contextmenu echo). */
suppressContextMenu: fired,
};