Skip to content

Commit 4fa663f

Browse files
committed
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)
1 parent 7c68ddd commit 4fa663f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎src/pages/fileBrowser/fileBrowser.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
860860
$list
861861
.querySelectorAll(".tile:not(.selection-header)")
862862
.forEach((item) => {
863+
if (item.dataset.notSelectable != null) return;
863864
const checkbox = Checkbox("", false);
864865
checkbox.onclick = () => {
865866
const url = item.querySelector("data-url").textContent;
@@ -912,12 +913,12 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
912913
const $el = e.target;
913914

914915
if (isSelectionMode) {
915-
const checkbox = $el.closest(".tile")?.querySelector(".input-checkbox");
916+
const $el2 = $el.closest(".tile");
917+
if ($el2?.dataset.notSelectable != null) return;
918+
const checkbox = $el2?.querySelector(".input-checkbox");
916919
if (checkbox && !$el.closest(".selection-header")) {
917920
checkbox.checked = !checkbox.checked;
918-
const url = $el
919-
.closest(".tile")
920-
.querySelector("data-url").textContent;
921+
const url = $el2.querySelector("data-url").textContent;
921922
if (checkbox.checked) {
922923
selectedItems.add(url);
923924
} else {
@@ -1394,12 +1395,14 @@ function FileBrowserInclude(mode, info, doesOpenLast = true) {
13941395
util.pushFolder(allStorages, strings["add a storage"], "", {
13951396
storageType: "notification",
13961397
uuid: "addstorage",
1398+
notSelectable: true,
13971399
});
13981400
}
13991401

14001402
if (IS_FILE_MODE) {
14011403
util.pushFolder(allStorages, "Select document", null, {
14021404
"open-doc": true,
1405+
notSelectable: true,
14031406
});
14041407
}
14051408

‎src/pages/fileBrowser/list.hbs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
type="{{type}}"
88
name="{{name}}"
99
{{#home}}home="{{.}}"{{/home}}
10+
{{#notSelectable}}data-not-selectable{{/notSelectable}}
1011
{{#open-doc}}open-doc="true"{{/open-doc}}
1112
{{#ftp-account}}ftp-account{{/ftp-account}}
1213
{{#disabled}}disabled{{/disabled}}

0 commit comments

Comments
 (0)