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().
This commit is contained in:
2026-05-09 14:42:17 +01:00
parent a97d05412e
commit f9707ebba8
+7
View File
@@ -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 // Rectangle selection
document.getElementById('entriesContainer').addEventListener('mousedown', function(e) { document.getElementById('entriesContainer').addEventListener('mousedown', function(e) {
if (rectState.active || e.button !== 0) return; if (rectState.active || e.button !== 0) return;