Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/collections/board: add collapse/expand all columns on mobile
Adorian Doran7c0562f2bf08
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsxindex 0a5cbcb6a1..1a55790bda 100644--- a/apps/client/src/widgets/collections/board/index.spec.tsx+++ b/apps/client/src/widgets/collections/board/index.spec.tsx@@ -5290,6 +5290,28 @@ describe("Selection mode on mobile", () => {await setup();expect(container.querySelector(".board-selection-toggle")).toBeNull();+ // The board offers these over its bottom corner instead, outside the header.+ expect(container.querySelector(".board-header-tools button.bx-collapse-alt")).toBeNull();+ expect(container.querySelector(".board-header-tools button.bx-expand-alt")).toBeNull();+ });++ /** What the desktop offers over the board's bottom corner, which a phone has no room for. */+ it("closes and opens every column from the header", async () => {+ await setup();+ const columns = () => [ ...container.querySelectorAll(".board-column") ];+ expect(columns().some(column => column.classList.contains("collapsed"))).toBe(false);++ await act(async () => {+ headerButton("bx-collapse-alt").click();+ await flush();+ });+ expect(columns().every(column => column.classList.contains("collapsed"))).toBe(true);++ await act(async () => {+ headerButton("bx-expand-alt").click();+ await flush();+ });+ expect(columns().some(column => column.classList.contains("collapsed"))).toBe(false);});/**diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex 09da3943d0..979fad7cd6 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -1405,6 +1405,8 @@ export default function BoardView({}}}onReset={stopSelecting}+ onCollapseAll={collapseAllColumns}+ onExpandAll={expandAllColumns}><BoardGroupBynote={parentNote}diff --git a/apps/client/src/widgets/collections/board/selection_bar.tsx b/apps/client/src/widgets/collections/board/selection_bar.tsxindex ceb758b996..552e55dfb8 100644--- a/apps/client/src/widgets/collections/board/selection_bar.tsx+++ b/apps/client/src/widgets/collections/board/selection_bar.tsx@@ -18,6 +18,9 @@ interface BoardHeaderToolsProps {onSelectColumn: () => void;/** Drops the selection and ends selection mode, the bar covering the button that started it. */onReset: () => void;+ /** Closes every column at once. On the desktop the board offers this over its bottom corner. */+ onCollapseAll: () => void;+ onExpandAll: () => void;}/**@@ -26,11 +29,24 @@ interface BoardHeaderToolsProps {* lasts a bar stands over all of it, with the count and what can be done with the selection.*/export default function BoardHeaderTools({- children, isSelecting, onToggleSelecting, count, canSelectColumn, onSelectColumn, onReset+ children, isSelecting, onToggleSelecting, count, canSelectColumn, onSelectColumn, onReset,+ onCollapseAll, onExpandAll}: BoardHeaderToolsProps) {return (<div className="board-header-tools">- {isMobile() && (+ {isMobile() && (<>+ <ActionButton+ icon="bx bx-collapse-alt"+ text={t("board_view.collapse-all-columns")}+ noTooltipOnTouch+ onClick={onCollapseAll}+ />+ <ActionButton+ icon="bx bx-expand-alt"+ text={t("board_view.expand-all-columns")}+ noTooltipOnTouch+ onClick={onExpandAll}+ /><ActionButtonclassName="board-selection-toggle"icon="bx bx-select-multiple"@@ -39,7 +55,7 @@ export default function BoardHeaderTools({noTooltipOnTouchonClick={onToggleSelecting}/>- )}+ </>)}{children}{isMobile() && isSelecting && (<div className="board-selection-bar" role="toolbar">