From f9707ebba8d64e7ddb9750492884b0043e880305 Mon Sep 17 00:00:00 2001 From: Zaki <18zaki18@gmail.com> Date: Sat, 9 May 2026 14:42:17 +0100 Subject: [PATCH] Add click-outside deselection (clear selection on mousedown outside any entry card) Document mousedown handler clears selection when clicking on any element that is not an entry card, the batch bar, or an open modal/settings menu. Works in tandem with entriesContainer rect-select handler: when clicking inside entriesContainer on empty space the container handler runs first (setting rectState.active=true) so the document handler skips; when clicking outside entriesContainer the document handler fires alone and calls clearSelection(). --- js/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/app.js b/js/app.js index 597954b..c8e32cb 100644 --- a/js/app.js +++ b/js/app.js @@ -1141,6 +1141,13 @@ if (token && curUser) { } })(); +// Click outside any entry card → clear selection +document.addEventListener('mousedown', function(e) { + if (e.button !== 0 || rectState.active) return; + if (e.target?.closest?.('.entry-card,.entry-row,.entry-compact,.table-row-drag,#batchBar,.custom-modal-overlay.show,.edit-modal.show,.modal-overlay.show,#genModal,#settingsMenu')) return; + if (selectedIds.size > 0) clearSelection(); +}); + // Rectangle selection document.getElementById('entriesContainer').addEventListener('mousedown', function(e) { if (rectState.active || e.button !== 0) return;