New tweak JS for clickable gear subtasks bugfix v2.3.0

This commit is contained in:
2026-08-04 10:57:10 -03:00
parent ca57a4044e
commit ddbd4c42a6
4 changed files with 85 additions and 2 deletions

View File

@@ -0,0 +1,57 @@
/*
* OrganonTweaks -- fix a core Kanboard touch bug on reorder tables.
*
* Kanboard inits the subtask / board-column / swimlane reorder sortables with
* handle:"td:first i", which matches EVERY <i> in a row's first cell -- so the gear/caret menu
* icons and the subtask status checkbox become drag handles too. On touch devices the bundled
* jQuery UI Touch Punch then captures the press on those icons, preventDefault()s the native
* tap-click, and only re-fires a click if the finger did not move at all -- so almost every real
* tap is swallowed and the menu never opens (the gear "drags" instead of opening).
*
* Fix: re-scope the handle option to the real drag icon (.draggable-row-handle) on every such
* sortable, so only the arrows drag and the other first-cell icons are plain clicks again.
* jQuery UI reads options.handle at press time, so this takes effect immediately, no re-init.
* Kanboard re-inits the sortable whenever it re-renders a table (subtask add/edit, column
* reorder, and so on), which re-applies the bad handle -- so we re-apply the fix after every
* render via a debounced MutationObserver. Always on (no setting). Harmless on desktop, where
* the mouse never takes the Touch Punch path.
*/
(function () {
"use strict";
var $j = window.jQuery;
if (! $j) {
return;
}
function fixHandles() {
$j(".ui-sortable").each(function () {
try {
var $s = $j(this);
if ($s.sortable("option", "handle") === "td:first i") {
$s.sortable("option", "handle", ".draggable-row-handle");
}
} catch (e) {
// element is not an initialized sortable -- skip it
}
});
}
var pending = false;
function schedule() {
if (pending) {
return;
}
pending = true;
window.setTimeout(function () {
pending = false;
fixHandles();
}, 0);
}
$j(fixHandles); // initial pass on DOM ready
new MutationObserver(schedule).observe(document.body, {
childList: true,
subtree: true
});
})();