Files
wekan/models/lib/touchDragClickGuard.js
Lauri Ojansivu 6c9ba47456 Prevent fast touch drags from opening cards
Suppress only the synchronous click that touch-punch emits after a jQuery UI sortable drag. Ordinary taps and later clicks retain their normal behavior.

Add positive and negative unit coverage plus a real fast-touch drag browser regression.

Thanks to xator91 and xet7 !

Fixes #5421,
2026-08-25 17:27:33 +03:00

27 lines
868 B
JavaScript

'use strict';
// Run a touch bridge's end handler while suppressing only the click it emits
// synchronously after a completed drag. Ordinary taps do not pass wasDragging,
// and later independent clicks are unaffected because the listener is removed
// before this function returns.
function runTouchEndWithoutPostDragClick(wasDragging, target, touchEnd) {
if (!wasDragging || !target || typeof target.addEventListener !== 'function') {
return touchEnd();
}
const suppressClick = event => {
event.preventDefault();
event.stopImmediatePropagation();
};
const listenerOptions = { capture: true };
target.addEventListener('click', suppressClick, listenerOptions);
try {
return touchEnd();
} finally {
target.removeEventListener('click', suppressClick, listenerOptions);
}
}
module.exports = { runTouchEndWithoutPostDragClick };