From 4fa663face5562c2bab6374ad5491a596ef6d2b6 Mon Sep 17 00:00:00 2001 From: AuDevTist1C <114492072+AuDevTist1C@users.noreply.github.com> Date: Sat, 25 Jul 2026 09:48:47 +0200 Subject: [PATCH] fix: introduce non-selectable item handling to isolate system utility tiles during batch operations Add non-selectable element safeguards across templates and touch selection handlers to prevent system utility tiles from being highlighted, checked, or included in multi-item batch actions. System notification tiles, such as "Add a storage" prompts and "Select document" system actions, reside in the same DOM list container as regular files and directories. Previously, initiating a "Select All" command or dragging across the file list would accidentally select these utility items, triggering runtime errors during batch operations like deletion or moving. * **Template Contract (`src/pages/fileBrowser/list.hbs`):** * Added support for the `data-not-selectable` HTML dataset attribute flag on list item nodes. * **Tile Configuration:** * Explicitly configured system utility tiles ("add a storage" and "Select document") with `notSelectable: true` in their template render context. * **Selection Safeguards (`src/pages/fileBrowser/fileBrowser.js`):** * Updated touch event delegation, long-press handlers, and "Select All" toggle utility functions to check for `dataset.notSelectable != null`. * Items flagged as non-selectable are automatically bypassed during selection count updates, bulk checkboxes, and context action payload generation. (AI generated commit message) --- src/pages/fileBrowser/fileBrowser.js | 11 +++++++---- src/pages/fileBrowser/list.hbs | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pages/fileBrowser/fileBrowser.js b/src/pages/fileBrowser/fileBrowser.js index 570cacee3..036df9674 100644 --- a/src/pages/fileBrowser/fileBrowser.js +++ b/src/pages/fileBrowser/fileBrowser.js @@ -860,6 +860,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { $list .querySelectorAll(".tile:not(.selection-header)") .forEach((item) => { + if (item.dataset.notSelectable != null) return; const checkbox = Checkbox("", false); checkbox.onclick = () => { const url = item.querySelector("data-url").textContent; @@ -912,12 +913,12 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { const $el = e.target; if (isSelectionMode) { - const checkbox = $el.closest(".tile")?.querySelector(".input-checkbox"); + const $el2 = $el.closest(".tile"); + if ($el2?.dataset.notSelectable != null) return; + const checkbox = $el2?.querySelector(".input-checkbox"); if (checkbox && !$el.closest(".selection-header")) { checkbox.checked = !checkbox.checked; - const url = $el - .closest(".tile") - .querySelector("data-url").textContent; + const url = $el2.querySelector("data-url").textContent; if (checkbox.checked) { selectedItems.add(url); } else { @@ -1394,12 +1395,14 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) { util.pushFolder(allStorages, strings["add a storage"], "", { storageType: "notification", uuid: "addstorage", + notSelectable: true, }); } if (IS_FILE_MODE) { util.pushFolder(allStorages, "Select document", null, { "open-doc": true, + notSelectable: true, }); } diff --git a/src/pages/fileBrowser/list.hbs b/src/pages/fileBrowser/list.hbs index a4ae77297..a8f118926 100644 --- a/src/pages/fileBrowser/list.hbs +++ b/src/pages/fileBrowser/list.hbs @@ -7,6 +7,7 @@ type="{{type}}" name="{{name}}" {{#home}}home="{{.}}"{{/home}} + {{#notSelectable}}data-not-selectable{{/notSelectable}} {{#open-doc}}open-doc="true"{{/open-doc}} {{#ftp-account}}ftp-account{{/ftp-account}} {{#disabled}}disabled{{/disabled}}