Fix rect selection in table view: prevent native text drag/selection

Added user-select:none and -webkit-user-drag:none to #entriesContainer.
Also added a dragstart listener that prevents default for any element
that is not [draggable='true'], stopping the browser from creating drag
ghosts of selected table text/headers during rectangle selection.
This commit is contained in:
2026-05-09 16:18:03 +01:00
parent efbf8f450a
commit 6a26dd78cb
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -128,6 +128,7 @@ input:focus, select:focus { border-color:var(--accent); }
#addFolderSelect { min-width:110px; max-width:150px; background:var(--input); border:1px solid #2d3748; color:var(--text); padding:0.5rem 0.8rem; border-radius:2rem; font-size:0.8rem; cursor:pointer; } #addFolderSelect { min-width:110px; max-width:150px; background:var(--input); border:1px solid #2d3748; color:var(--text); padding:0.5rem 0.8rem; border-radius:2rem; font-size:0.8rem; cursor:pointer; }
/* Entries */ /* Entries */
#entriesContainer { user-select:none; -webkit-user-drag:none; }
#entriesContainer.grid-view { display:grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap:0.6rem; } #entriesContainer.grid-view { display:grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap:0.6rem; }
#entriesContainer.list-view { display:flex; flex-direction:column; gap:0.4rem; } #entriesContainer.list-view { display:flex; flex-direction:column; gap:0.4rem; }
#entriesContainer.compact-view { display:flex; flex-direction:column; gap:0.2rem; } #entriesContainer.compact-view { display:flex; flex-direction:column; gap:0.2rem; }
+5
View File
@@ -1141,6 +1141,11 @@ if (token && curUser) {
} }
})(); })();
// Prevent native drag on non-card elements (table headers, text, etc.)
document.getElementById('entriesContainer').addEventListener('dragstart', function(e) {
if (!e.target?.closest?.('[draggable="true"]')) e.preventDefault();
});
// Document mousedown: rect selection on vault background, clear outside vault // Document mousedown: rect selection on vault background, clear outside vault
document.addEventListener('mousedown', function(e) { document.addEventListener('mousedown', function(e) {
if (e.button !== 0 || rectState.active) return; if (e.button !== 0 || rectState.active) return;