Skip to content

Build your personal knowledge base with Trilium Notes

fix(collections/dashboard): disable resizing and reordering on small sizes

Elian Doran3ccca7f4fc44
diff --git a/apps/client/src/widgets/collections/dashboard/index.css b/apps/client/src/widgets/collections/dashboard/index.css
index f98582eac5..484f0152da 100644
--- a/apps/client/src/widgets/collections/dashboard/index.css
+++ b/apps/client/src/widgets/collections/dashboard/index.css
@@ -22,6 +22,10 @@
}
}
+ .grid-stack-static .dashboard-widget-header {
+ cursor: default;
+ }
+
.dashboard-widget-header {
display: flex;
align-items: center;
diff --git a/apps/client/src/widgets/collections/dashboard/index.tsx b/apps/client/src/widgets/collections/dashboard/index.tsx
index 4155265f9b..374b454686 100644
--- a/apps/client/src/widgets/collections/dashboard/index.tsx
+++ b/apps/client/src/widgets/collections/dashboard/index.tsx
@@ -11,7 +11,7 @@ import linkContextMenuService from "../../../menus/link_context_menu";
import froca from "../../../services/froca";
import CollectionProperties from "../../note_bars/CollectionProperties";
import ActionButton from "../../react/ActionButton";
-import { useNoteLabelBoolean, useSpacedUpdate } from "../../react/hooks";
+import { useElementSize, useNoteLabelBoolean, useSpacedUpdate } from "../../react/hooks";
import Icon from "../../react/Icon";
import NoteLink from "../../react/NoteLink";
import { ViewModeProps } from "../interface";
@@ -54,6 +54,14 @@ export default function DashboardView({ note, noteIds, viewConfig, saveConfig, h
froca.getNotes(noteIds).then(setNotes);
}, [ noteIds ]);
+ // Dragging and resizing don't work meaningfully in the collapsed single-column mode
+ // (the rearrangement would not be persisted anyway), so disable them entirely there.
+ const containerSize = useElementSize(containerRef);
+ const isCollapsed = (containerSize?.width ?? Number.POSITIVE_INFINITY) < SINGLE_COLUMN_BREAKPOINT;
+ useEffect(() => {
+ gridRef.current?.setStatic(isCollapsed);
+ }, [ isCollapsed ]);
+
function persistLayout(grid: GridStack) {
if (grid.getColumn() !== GRID_COLUMNS) {
// Collapsed responsive mode — the geometry is a derived single-column layout;