fix: delay context menu to prevent broken input loop on macOS, closes #3324 (#3378)

When a native context menu is triggered via right-click, the menu.popup()
call immediately takes control and disrupts the browser's pointer event
flow. This prevents the pointerUp event from being delivered, leaving the
input event loop in an inconsistent state where the first tap after
dismissing the menu is not captured.

The fix adds a 100ms delay before showing the context menu, allowing the
browser's input loop to complete the pointerUp event for the right-click
before the native menu interferes.
This commit is contained in:
Huang Xin
2026-02-25 18:22:25 +08:00
committed by GitHub
parent 534582b125
commit 3e7b57282e
+3 -1
View File
@@ -140,7 +140,9 @@ export const useLongPress = (
if (onContextMenu) {
e.preventDefault();
e.stopPropagation();
onContextMenu();
setTimeout(() => {
onContextMenu();
}, 100);
}
reset();
},