mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
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,
27 lines
868 B
JavaScript
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 };
|