Grid view: arrow up/down moves vertically by column count; left/right moves linearly

This commit is contained in:
2026-05-09 23:23:30 +01:00
parent b0785fbe8d
commit 3802f1fc23
+13
View File
@@ -672,6 +672,14 @@ function getFilteredEntries(noFolder) {
return entries.filter(e => (e.folder || 'All') === selectedFolder);
}
function getGridCols() {
const c = document.getElementById('entriesContainer');
if (!c || !c.firstElementChild) return 1;
const w = c.firstElementChild.offsetWidth;
const gap = parseInt(getComputedStyle(c).columnGap) || 0;
return Math.max(1, Math.round(c.offsetWidth / (w + gap)));
}
// ==================== RENDER ====================
function render() {
const c = document.getElementById('entriesContainer');
@@ -1420,8 +1428,13 @@ document.addEventListener('keydown', function(e) {
const firstId = [...selectedIds][0];
idx = filtered.findIndex(e => e.id == firstId);
}
if (view === 'grid' && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
if (idx < 0) idx = 0;
else { const cols = getGridCols(); if (e.key === 'ArrowDown') { const next = idx + cols; idx = next < filtered.length ? next : idx; } else { const prev = idx - cols; idx = prev >= 0 ? prev : idx; } }
} else {
if (isNext) idx = idx < filtered.length - 1 ? idx + 1 : 0;
else idx = idx > 0 ? idx - 1 : filtered.length - 1;
}
if (e.shiftKey) {
const anchorId = lastSelectedId !== null ? lastSelectedId : filtered[idx].id;
const anchor = filtered.findIndex(e => e.id == anchorId);