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:
@@ -550,10 +550,10 @@ function useGlobalLongPress(isMobile: boolean) {
|
||||
};
|
||||
|
||||
const onTouchStart = (e: TouchEvent) => {
|
||||
const target = e.target as HTMLElement;
|
||||
if (target.closest('[data-context-menu]')) {
|
||||
e.preventDefault();
|
||||
}
|
||||
// NOTE: Do NOT call e.preventDefault() here — it kills the synthesized
|
||||
// click event on mobile (touchstart → touchend → click chain).
|
||||
// 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; }
|
||||
const touch = e.touches[0]!;
|
||||
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('touchend', onTouchEnd, { passive: true });
|
||||
document.addEventListener('touchcancel', onTouchEnd, { passive: true });
|
||||
|
||||
Reference in New Issue
Block a user