Test only use longpress for iOS

This commit is contained in:
Lim Chee Aun 2023-10-01 17:14:32 +08:00
parent d05f0a4f23
commit a364488895

View file

@ -789,8 +789,17 @@ function Status({
x: 0, x: 0,
y: 0, y: 0,
}); });
const isIOS =
window.ontouchstart !== undefined &&
/iPad|iPhone|iPod/.test(navigator.userAgent);
// Only iOS/iPadOS browsers don't support contextmenu
// Some comments report iPadOS might support contextmenu if a mouse is connected
const bindLongPressContext = useLongPress( const bindLongPressContext = useLongPress(
(e) => { isIOS
? (e) => {
if (e.pointerType === 'mouse') return;
// There's 'pen' too, but not sure if contextmenu event would trigger from a pen
const { clientX, clientY } = e.touches?.[0] || e; const { clientX, clientY } = e.touches?.[0] || e;
// link detection copied from onContextMenu because here it works // link detection copied from onContextMenu because here it works
const link = e.target.closest('a'); const link = e.target.closest('a');
@ -801,7 +810,8 @@ function Status({
y: clientY, y: clientY,
}); });
setIsContextMenuOpen(true); setIsContextMenuOpen(true);
}, }
: null,
{ {
threshold: 600, threshold: 600,
captureEvent: true, captureEvent: true,