fix: remove preventDefault on touchstart that killed all mobile taps

Calling e.preventDefault() on touchstart inside [data-context-menu]
elements prevented the browser from synthesizing click events
(touchstart → touchend → click chain). This broke tapping on spaces,
channels, DMs, and every other surface with data-context-menu.

Text selection prevention is already handled by CSS user-select: none
on [data-context-menu] elements — the JS preventDefault was redundant
and destructive. Reverted touchstart listener back to passive.
This commit is contained in:
Jannis Braun
2026-03-24 00:14:09 +01:00
parent 8897a5894c
commit 2b2e1c7386
@@ -550,10 +550,10 @@ function useGlobalLongPress(isMobile: boolean) {
}; };
const onTouchStart = (e: TouchEvent) => { const onTouchStart = (e: TouchEvent) => {
const target = e.target as HTMLElement; // NOTE: Do NOT call e.preventDefault() here — it kills the synthesized
if (target.closest('[data-context-menu]')) { // click event on mobile (touchstart → touchend → click chain).
e.preventDefault(); // Text selection prevention is handled by CSS user-select: none on
} // [data-context-menu] elements (see globals.css).
if (e.touches.length !== 1) { cancel(); return; } if (e.touches.length !== 1) { cancel(); return; }
const touch = e.touches[0]!; const touch = e.touches[0]!;
originX = touch.clientX; originX = touch.clientX;
@@ -604,7 +604,7 @@ function useGlobalLongPress(isMobile: boolean) {
} }
}; };
document.addEventListener('touchstart', onTouchStart, { passive: false }); document.addEventListener('touchstart', onTouchStart, { passive: true });
document.addEventListener('touchmove', onTouchMove, { passive: true }); document.addEventListener('touchmove', onTouchMove, { passive: true });
document.addEventListener('touchend', onTouchEnd, { passive: true }); document.addEventListener('touchend', onTouchEnd, { passive: true });
document.addEventListener('touchcancel', onTouchEnd, { passive: true }); document.addEventListener('touchcancel', onTouchEnd, { passive: true });