Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: collapse columns without results while the view is filtered

Adorian Doran5f2ec71b122c
diff --git a/apps/client/src/widgets/collections/board/api.spec.ts b/apps/client/src/widgets/collections/board/api.spec.ts
index 2571f82b41..58a269139a 100644
--- a/apps/client/src/widgets/collections/board/api.spec.ts
+++ b/apps/client/src/widgets/collections/board/api.spec.ts
@@ -1635,6 +1635,28 @@ describe("collapsing a column", () => {
expect(saved.at(-1)?.columns).toEqual([ { value: "To Do" }, { value: "Done" } ]);
});
+ /** While a filter is on, the board holds the collapse state and nothing reaches the config. */
+ it("answers to the volatile collapse in place of the stored flags while set", async () => {
+ const { api, saved } = createApi(
+ { columns: [ { value: "To Do", collapsed: true, keepCollapsed: true } ] },
+ [ "To Do", "Done" ]);
+ const setCollapsed = vi.fn();
+ api.volatileCollapse = { isCollapsed: (column) => column === "Done", setCollapsed };
+
+ expect(api.isColumnCollapsed("To Do")).toBe(false);
+ expect(api.isColumnCollapsed("Done")).toBe(true);
+ expect(api.isColumnKeptCollapsed("To Do")).toBe(false);
+
+ await api.setColumnCollapsed("Done", false);
+ await api.setAllColumnsCollapsed(true);
+ expect(setCollapsed.mock.calls).toEqual([ [ "Done", false ], [ null, true ] ]);
+ expect(saved).toEqual([]);
+
+ api.volatileCollapse = undefined;
+ expect(api.isColumnCollapsed("To Do")).toBe(true);
+ expect(api.isColumnKeptCollapsed("To Do")).toBe(true);
+ });
+
/**
* Turning it on collapses the column as well, so the entry does something the reader can see
* rather than only deciding what the next open does.
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.ts
index b77263dcd0..c7a18b79a0 100644
--- a/apps/client/src/widgets/collections/board/api.ts
+++ b/apps/client/src/widgets/collections/board/api.ts
@@ -62,6 +62,19 @@ interface ColumnClaim {
* taken back from under another leaves the one above it standing, and a column with no claims left
* has no record at all, whichever of the two failed first.
*/
+/**
+ * The collapse state the board draws while a filter narrows it, in place of the stored flags.
+ *
+ * A column without matches is drawn as a strip so the results are read at a glance, and what the
+ * reader opens or closes meanwhile is held by the board rather than written: clearing the filter
+ * brings the stored state back.
+ */
+export interface VolatileCollapse {
+ isCollapsed(column: string): boolean;
+ /** Opens or closes one column, or every column when given `null`. */
+ setCollapsed(column: string | null, collapsed: boolean): void;
+}
+
export interface PendingColumnWrites {
renames: Map<string, string | undefined>;
claims: Map<string, ColumnClaim[]>;
@@ -130,6 +143,12 @@ export default class BoardApi {
*/
noteContext: NoteContext | null | undefined;
+ /**
+ * Stands in for the stored collapse flags while a filter is on, set by the board on every
+ * render and cleared with the filter. See {@link VolatileCollapse}.
+ */
+ volatileCollapse: VolatileCollapse | undefined;
+
/** The config as the board last handed it over, against which a fresh one is recognised. */
private viewConfigSource: BoardViewData | undefined;
private viewConfig: BoardViewData;
@@ -983,11 +1002,20 @@ export default class BoardApi {
/** Whether a column is stored as collapsed, which draws it as a strip without its cards. */
isColumnCollapsed(column: string) {
+ if (this.volatileCollapse) {
+ return this.volatileCollapse.isCollapsed(column);
+ }
+
return !!this.storedColumns.find(col => col.value === column)?.collapsed;
}
- /** Collapses a column to a strip, or opens it again. */
+ /** Collapses a column to a strip, or opens it again. Not written while a filter is on. */
async setColumnCollapsed(column: string, collapsed: boolean) {
+ if (this.volatileCollapse) {
+ this.volatileCollapse.setCollapsed(column, collapsed);
+ return;
+ }
+
this.updateColumn(column, { collapsed });
}
@@ -998,6 +1026,11 @@ export default class BoardApi {
* carry is drawn without ever having been stored, so this is also where it gets an entry.
*/
async setAllColumnsCollapsed(collapsed: boolean) {
+ if (this.volatileCollapse) {
+ this.volatileCollapse.setCollapsed(null, collapsed);
+ return;
+ }
+
const stored = new Map(this.storedColumns.map(col => [ col.value, col ]));
const order = [ ...stored.keys() ];
for (const derived of this.columns) {
@@ -1019,9 +1052,10 @@ export default class BoardApi {
}));
}
- /** Whether a column collapses again once it has been opened. */
+ /** Whether a column collapses again once it has been opened. Never while a filter is on. */
isColumnKeptCollapsed(column: string) {
- return !!this.storedColumns.find(col => col.value === column)?.keepCollapsed;
+ return !this.volatileCollapse
+ && !!this.storedColumns.find(col => col.value === column)?.keepCollapsed;
}
/**
diff --git a/apps/client/src/widgets/collections/board/column.tsx b/apps/client/src/widgets/collections/board/column.tsx
index 3172b2c7e4..6229b431f6 100644
--- a/apps/client/src/widgets/collections/board/column.tsx
+++ b/apps/client/src/widgets/collections/board/column.tsx
@@ -72,6 +72,9 @@ export default function Column({
archived,
collapsed,
keepCollapsed,
+ isCollapseVolatile,
+ collapsesQuickly,
+ willOpen,
isActive,
isPeeked,
isResizing,
@@ -99,6 +102,18 @@ export default function Column({
collapsed?: boolean,
/** Whether the column collapses again once opened, which keeps `collapsed` through an open. */
keepCollapsed?: boolean,
+ /**
+ * Whether `collapsed` is the filter's rather than the stored flag, so a change to it is not
+ * written and the column is not offered to keep collapsed.
+ */
+ isCollapseVolatile?: boolean,
+ /** Whether a collapse now being drawn was asked for, which runs at the quick duration. */
+ collapsesQuickly?: boolean,
+ /**
+ * Whether the column is about to open, while it is still drawn as a strip. It lays its cards
+ * out meanwhile, so the open does not pay for that on the frame the width starts moving.
+ */
+ willOpen?: boolean,
/** Whether this is the column the reader is working in, which opens it while it is collapsed. */
isActive?: boolean,
/** Whether the board is showing every collapsed column at once, which opens this one too. */
@@ -351,7 +366,7 @@ export default function Column({
* hidden rather than taken out, which is what makes closing one cheap.
*/
const [ isDrawn, setIsDrawn ] = useState(!isCollapsed);
- if (!isDrawn && !isCollapsed) {
+ if (!isDrawn && (!isCollapsed || willOpen)) {
setIsDrawn(true);
}
@@ -455,6 +470,7 @@ export default function Column({
canRename: !isCollapsed,
isCollapsed,
keepCollapsed,
+ canKeepCollapsed: !isCollapseVolatile,
nested,
onEditTitle: () => setColumnNameToEdit(column),
onNewItem: beginNewItem,
@@ -480,7 +496,8 @@ export default function Column({
}
});
}, [
- api, column, color, archived, collapsed, keepCollapsed, collapse, isCollapsed, nested,
+ api, column, color, archived, collapsed, keepCollapsed, isCollapseVolatile, collapse,
+ isCollapsed, nested,
columns, columnIndex, setColumnNameToEdit, setColumnLimitToEdit, setActiveColumn,
onMoveColumn, onFocusColumn
]);
@@ -612,7 +629,8 @@ export default function Column({
windowed: isWindowed,
"over-limit": isOverLimit,
collapsed: isCollapsed,
- "quick-collapse": isCollapsingByHand,
+ "pre-expanding": isCollapsed && willOpen,
+ "quick-collapse": isCollapsingByHand || collapsesQuickly,
// Opening is drawn for the reader who asked for it. A column opened to take a
// dragged card takes its width at once, since the drop is measured as it opens.
"quick-expand": !isCollapsed && !opensAtOnce,
diff --git a/apps/client/src/widgets/collections/board/context_menu.spec.ts b/apps/client/src/widgets/collections/board/context_menu.spec.ts
index 7b92b3a4ba..48f471a206 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -47,7 +47,7 @@ describe("Board column context menu", () => {
column: {
value?: string, color?: string, archived?: boolean, collapsed?: boolean,
keepCollapsed?: boolean, isCollapsed?: boolean, canRename?: boolean,
- columns?: string[], index?: number, nested?: boolean
+ canKeepCollapsed?: boolean, columns?: string[], index?: number, nested?: boolean
} = {},
callbacks: {
onEditTitle?: () => void,
@@ -80,6 +80,7 @@ describe("Board column context menu", () => {
columns: [ "To Do" ],
index: 0,
canRename: true,
+ canKeepCollapsed: true,
...column,
onEditTitle: callbacks.onEditTitle ?? (() => {}),
onNewItem: callbacks.onNewItem ?? (() => {}),
@@ -175,6 +176,10 @@ describe("Board column context menu", () => {
expect("trailingIcon" in checked && checked.trailingIcon).toBe("bx bx-check");
checked.handler?.(checked, {} as never);
expect(onKeepCollapsed).toHaveBeenLastCalledWith(false);
+
+ // Withheld while a filter decides what is collapsed, since nothing is stored then.
+ expect(openMenu({} as BoardApi, { canKeepCollapsed: false }).some(item =>
+ item && "uiIcon" in item && item.uiIcon === "bx bx-lock-alt")).toBe(false);
});
/** The strip has no title to edit, so the menu does not offer to edit one either. */
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index 35f378c345..deae8f8f05 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -35,6 +35,8 @@ interface ColumnMenuTarget {
isCollapsed?: boolean;
/** Whether the title can be edited. False for a collapsed column, rendered as a strip. */
canRename: boolean;
+ /** Whether the column can be kept collapsed. False while a filter decides what is collapsed. */
+ canKeepCollapsed: boolean;
/** Whether the inbox also collects notes deeper than the board's direct children. */
nested?: boolean;
/** Opens the inline title editor, which F2 also opens. */
@@ -128,13 +130,13 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
uiIcon: "bx bx-collapse-horizontal",
handler: () => column.onCollapse(true)
} ]),
- {
+ ...(column.canKeepCollapsed ? [ {
title: t("board_view.keep-column-collapsed"),
uiIcon: "bx bx-lock-alt",
// At the trailing edge, so the entry keeps its own icon in front.
trailingIcon: column.keepCollapsed ? "bx bx-check" : undefined,
handler: () => column.onKeepCollapsed(!column.keepCollapsed)
- },
+ } ] : []),
{
title: t("board_view.sort"),
uiIcon: "bx bx-sort-alt-2",
diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.css
index 16a0fc72ac..820ba848f8 100644
--- a/apps/client/src/widgets/collections/board/index.css
+++ b/apps/client/src/widgets/collections/board/index.css
@@ -1230,6 +1230,14 @@ body.mobile .column-drop-placeholder {
padding-block: 0;
}
+/* A strip about to open lays its cards out while it waits, at the width they open to, so the open
+ finds them laid out. No height, so the strip stays as tall as its heading. */
+.board-view-container .board-column.collapsed.pre-expanding > .board-column-content {
+ content-visibility: visible;
+ width: calc(var(--board-column-width) - 2 * var(--board-column-border-width));
+ max-height: 0;
+}
+
/* Width and not a transform: the columns beside it have to move with it. The copy being carried is
left out, or it would ease towards each frame's position instead of taking it: its `transition:
none` above carries no more weight than this rule and stands above it in the file. */
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index 905aeb59cb..2e69cf555f 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -131,6 +131,11 @@ async function flush() {
await new Promise((resolve) => setTimeout(resolve));
}
+/** Lets one animation frame run. */
+async function nextFrame() {
+ await new Promise((resolve) => requestAnimationFrame(resolve));
+}
+
/** Fills a field the way typing does, so that what watches the field hears about it. */
async function type(field: HTMLInputElement | HTMLTextAreaElement, value: string) {
await act(async () => {
@@ -3589,10 +3594,12 @@ describe("Board filtering", () => {
});
/** A board of four cards over two columns, opened with a stored filter query. */
- async function setup({ matched, tokens = [], limit }: {
+ async function setup({ matched, tokens = [], limit, columns }: {
matched: string[];
tokens?: { token: string; type: "plain" }[];
limit?: number;
+ /** The stored columns, in place of an open "To Do" and "Done". */
+ columns?: BoardViewData["columns"];
}) {
searchInSubtree.mockReset();
searchInSubtree.mockResolvedValue({
@@ -3603,6 +3610,8 @@ describe("Board filtering", () => {
const note = buildNote({
title: "Board",
+ // The header the filter box stands in is drawn for a collection note alone.
+ type: "book",
"#collection": "",
"#viewType": "board",
children: [
@@ -3622,7 +3631,7 @@ describe("Board filtering", () => {
note={note}
noteIds={[ ...note.getChildNoteIds() ]}
initialConfig={{
- columns: [ { value: "To Do", ...(limit ? { limit } : {}) },
+ columns: columns ?? [ { value: "To Do", ...(limit ? { limit } : {}) },
{ value: "Done" } ],
filterQuery: "#urgent"
}}
@@ -3643,6 +3652,26 @@ describe("Board filtering", () => {
.map(el => el.textContent);
}
+ /** Presses the filter's clear button, which stands in the collection header. */
+ async function clearFilter() {
+ const clear = container.querySelector<HTMLElement>(".collection-filter-clear");
+ if (!clear) throw new Error("expected the filter's clear button");
+ await act(async () => {
+ clear.click();
+ await flush();
+ });
+ }
+
+ /**
+ * Lets animation frames run, one pass each: a render is flushed only as a pass ends. The
+ * hold takes two frames, and the release is drawn on the one after.
+ */
+ async function nextFrames(count: number) {
+ for (let frame = 0; frame < count; frame++) {
+ await act(async () => { await nextFrame(); });
+ }
+ }
+
/** A branch change under the board, which is what re-runs an active filter. */
function branchChange(parentNoteId: string, noteId: string) {
const results = new LoadResults([ {
@@ -3791,6 +3820,89 @@ describe("Board filtering", () => {
const marks = [ ...container.querySelectorAll(".board-note .title .ck-find-result") ];
expect(marks.map(el => el.textContent)).toEqual([ "First" ]);
});
+
+ /**
+ * The stored flags are set aside while the filter is on: a column without a match is drawn as
+ * a strip whatever is stored for it, one with a match is drawn open, and what the reader opens
+ * meanwhile is held by the board rather than written. Clearing the filter brings the stored
+ * state back, the hand-opened column included.
+ */
+ it("collapses the columns the filter leaves empty, without writing, until it is cleared",
+ async () => {
+ await setup({ matched: [ "filtered1" ], columns: [
+ { value: "To Do", collapsed: true, keepCollapsed: true },
+ { value: "Done" }
+ ] });
+ const isCollapsed = (index: number) =>
+ container.querySelectorAll(".board-column")[index].classList.contains("collapsed");
+
+ expect(isCollapsed(0)).toBe(false);
+ expect(cardTitles(0)).toEqual([ "First" ]);
+ expect(isCollapsed(1)).toBe(true);
+
+ // A click on the strip opens the column, and keeps it open once focus moves on: the
+ // stored `keepCollapsed` has no say either, so the kept column is not closed by it.
+ const done = container.querySelectorAll<HTMLElement>(".board-column")[1];
+ await act(async () => {
+ done.dispatchEvent(new Event("pointerdown", { bubbles: true }));
+ document.dispatchEvent(new Event("pointerup", { bubbles: true }));
+ done.dispatchEvent(new Event("click", { bubbles: true }));
+ });
+ expect(isCollapsed(1)).toBe(false);
+ const todo = container.querySelectorAll<HTMLElement>(".board-column")[0];
+ await act(async () => {
+ todo.dispatchEvent(new Event("focusin", { bubbles: true }));
+ });
+ expect(isCollapsed(0)).toBe(false);
+ expect(isCollapsed(1)).toBe(false);
+ expect(saved).toEqual([]);
+
+ await clearFilter();
+ // The one the reader opened stays open through the clear: it is stored open, and the
+ // override is dropped with the results it was made against, not with the query.
+ expect(isCollapsed(1)).toBe(false);
+ await nextFrames(3);
+
+ expect(isCollapsed(0)).toBe(true);
+ expect(isCollapsed(1)).toBe(false);
+ expect(cardTitles(1)).toEqual([ "Fourth" ]);
+ // Clearing the filter is the only write, and it leaves the columns as they were stored.
+ expect(saved.at(-1)?.columns).toEqual([
+ { value: "To Do", collapsed: true, keepCollapsed: true },
+ { value: "Done" }
+ ]);
+ });
+
+ /**
+ * The cards come back first, and the columns keep their widths for two frames so the width
+ * transitions do not run over the card redraw; only then is the stored state drawn. A strip
+ * about to open draws its cards meanwhile, so the open finds them laid out.
+ */
+ it("holds the columns' widths for two frames after the filter is cleared", async () => {
+ await setup({ matched: [ "filtered1" ], columns: [
+ { value: "To Do", collapsed: true },
+ { value: "Done" }
+ ] });
+ const columnAt = (index: number) => container.querySelectorAll(".board-column")[index];
+ expect(columnAt(0).classList.contains("collapsed")).toBe(false);
+ expect(columnAt(1).classList.contains("collapsed")).toBe(true);
+
+ await clearFilter();
+
+ expect(cardTitles(0)).toEqual([ "First", "Second", "Third" ]);
+ expect(columnAt(0).classList.contains("collapsed")).toBe(false);
+ expect(columnAt(1).classList.contains("collapsed")).toBe(true);
+ expect(columnAt(1).classList.contains("pre-expanding")).toBe(true);
+ expect(columnAt(1).querySelectorAll(".board-note")).toHaveLength(1);
+ await nextFrames(3);
+
+ expect(columnAt(0).classList.contains("collapsed")).toBe(true);
+ // A collapse the filter asked for runs at the quick pace, like one asked for by hand.
+ expect(columnAt(0).classList.contains("quick-collapse")).toBe(true);
+ expect(columnAt(1).classList.contains("collapsed")).toBe(false);
+ expect(columnAt(1).classList.contains("pre-expanding")).toBe(false);
+ expect(cardTitles(1)).toEqual([ "Fourth" ]);
+ });
});
describe("a column that sorts its cards", () => {
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index 18c8929c72..0f301ea94d 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -274,6 +274,9 @@ export const BoardKeptCardsContext = createContext<Set<string>>(new Set());
/** Shared empty set for a board with no insert field open, so no render allocates one. */
const NO_COLUMNS: ReadonlySet<string> = new Set();
+/** Shared empty map for a filter under which no column has been opened or closed by hand. */
+const NO_FILTER_COLLAPSE: ReadonlyMap<string, boolean> = new Map();
+
/** How long a finger stays on the create button before it offers where to put the card. */
const HOLD_TO_PLACE_MS = 500;
@@ -639,6 +642,77 @@ export default function BoardView({
includeArchived || !storedColumns.get(column)?.archived),
[ usableColumns, storedColumns, includeArchived ]);
+ // The columns the reader opened or closed while the filter is on. Held here rather than
+ // written: the filter decides what is drawn open, and clearing it brings the stored state back.
+ const [ filterCollapse, setFilterCollapse ] =
+ useState<ReadonlyMap<string, boolean>>(NO_FILTER_COLLAPSE);
+ const isFiltering = filter.shownNoteIds !== null;
+ // New results start afresh, and the peeked column closes with the old ones, or it would stay
+ // open while empty. Keyed on the results rather than on the query, which changes a render
+ // earlier: reset then, the map would be applied to the old results first.
+ const [ filterCollapseResults, setFilterCollapseResults ] = useState(filter.shownNoteIds);
+ if (filterCollapseResults !== filter.shownNoteIds) {
+ setFilterCollapseResults(filter.shownNoteIds);
+ setFilterCollapse(NO_FILTER_COLLAPSE);
+ selectColumn(undefined);
+ }
+ /**
+ * Which columns are to be drawn as strips. While a filter is on, the ones it leaves without a
+ * card, so the matches are read at a glance; otherwise the ones stored as collapsed.
+ */
+ const targetCollapse = useMemo(
+ () => new Map(shownColumns.map(column => [ column, isFiltering
+ ? filterCollapse.get(column) ?? !byColumn?.get(column)?.length
+ : !!storedColumns.get(column)?.collapsed ])),
+ [ shownColumns, isFiltering, filterCollapse, byColumn, storedColumns ]);
+ /**
+ * The target released from a hold, which is then drawn. A hold is a target that arrived with
+ * new cards, which is a filter resolving or being cleared: drawn in the same commit, the width
+ * transitions would run over the frames the card redraw needs, so the columns keep their
+ * widths for two frames first. A change by hand arrives with the cards unchanged and is drawn
+ * at once.
+ */
+ const [ releasedCollapse, setReleasedCollapse ] = useState<ReadonlyMap<string, boolean>>();
+ /** What the last unheld render drew, which a hold keeps drawing. */
+ const drawnCollapse = useRef<{ collapse: ReadonlyMap<string, boolean>, cards?: ColumnMap }>();
+ const isCollapseHeld = releasedCollapse !== targetCollapse
+ && drawnCollapse.current?.cards !== undefined && drawnCollapse.current.cards !== byColumn
+ && sameColumns(drawnCollapse.current.collapse, targetCollapse)
+ && !sameCollapse(drawnCollapse.current.collapse, targetCollapse);
+ /** Which columns are drawn as strips. */
+ const collapsedColumns = isCollapseHeld && drawnCollapse.current
+ ? drawnCollapse.current.collapse
+ : targetCollapse;
+ if (!isCollapseHeld) {
+ drawnCollapse.current = { collapse: targetCollapse, cards: byColumn };
+ }
+ useEffect(() => {
+ if (!isCollapseHeld) {
+ return;
+ }
+
+ // Two frames: the first paints the cards, the second starts the widths moving.
+ let second: number | undefined;
+ const first = requestAnimationFrame(() => {
+ second = requestAnimationFrame(() => setReleasedCollapse(targetCollapse));
+ });
+ return () => {
+ cancelAnimationFrame(first);
+ if (second !== undefined) {
+ cancelAnimationFrame(second);
+ }
+ };
+ }, [ isCollapseHeld, targetCollapse ]);
+ // A release is the filter's doing, so the columns it closes run at the quick pace.
+ const isCollapsedByFilter = releasedCollapse === targetCollapse;
+ // Set here rather than passed in, like `noteContext`: the api outlives a refresh.
+ api.volatileCollapse = isFiltering ? {
+ isCollapsed: (column) => !!collapsedColumns.get(column),
+ setCollapsed: (column, collapsed) => setFilterCollapse(current => (column === null
+ ? new Map(shownColumns.map(each => [ each, collapsed ]))
+ : new Map(current).set(column, collapsed)))
+ } : undefined;
+
const containerRef = useRef<HTMLDivElement>(null);
/** Until when a column move can still be settling, which is when `useFlip` slides columns. */
const columnMovedUntil = useRef(0);
@@ -725,7 +799,7 @@ export default function BoardView({
const columnResizingUntil = useRef(0);
const columnWidths = useRef<string>();
const widths = shownColumns
- .map(column => storedColumns.get(column)?.collapsed
+ .map(column => collapsedColumns.get(column)
&& column !== activeColumn && !isPeekingAll ? "1" : "0")
.join("");
if (columnWidths.current !== undefined && columnWidths.current !== widths) {
@@ -886,7 +960,7 @@ export default function BoardView({
// Answers for what a `dragover` did, for a collapsed column the card is actually over:
// one merely passed near keeps to itself, and one already opened stays open, since
// closing it under a drag would move every column after it.
- if (position && inside && storedColumns.get(position.column)?.collapsed) {
+ if (position && inside && collapsedColumns.get(position.column)) {
selectColumn(position.column);
}
},
@@ -1330,8 +1404,13 @@ export default function BoardView({
icon={storedColumns.get(column)?.icon}
color={storedColumns.get(column)?.color}
archived={storedColumns.get(column)?.archived}
- collapsed={storedColumns.get(column)?.collapsed}
- keepCollapsed={storedColumns.get(column)?.keepCollapsed}
+ collapsed={collapsedColumns.get(column)}
+ keepCollapsed={isFiltering
+ ? undefined
+ : storedColumns.get(column)?.keepCollapsed}
+ isCollapseVolatile={isFiltering}
+ collapsesQuickly={isCollapsedByFilter}
+ willOpen={isCollapseHeld && !targetCollapse.get(column)}
isActive={activeColumn === column}
isPeeked={isPeekingAll}
isResizing={isResizingColumns}
@@ -1433,6 +1512,17 @@ export default function BoardView({
/** How long the board waits for a move's changes before drawing again regardless. */
const SETTLE_TIMEOUT_MS = 10000;
+/** Whether two collapse maps hold the same columns. */
+function sameColumns(a: ReadonlyMap<string, boolean>, b: ReadonlyMap<string, boolean>) {
+ return a.size === b.size && [ ...a.keys() ].every(column => b.has(column));
+}
+
+/** Whether two collapse maps hold the same columns and agree on each. */
+function sameCollapse(a: ReadonlyMap<string, boolean>, b: ReadonlyMap<string, boolean>) {
+ return sameColumns(a, b)
+ && [ ...a ].every(([ column, collapsed ]) => b.get(column) === collapsed);
+}
+
/**
* Waits for `froca` to hold what a move has written.
*