Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix some issues

Adorian Doranb13bade0d334
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 6bae2dc89e..a9b49a3a0d 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3520,7 +3520,7 @@
"new-template-name": "New card template",
"more-templates": "More templates…",
"card-template": "Select a card template",
- "collapse-hint": "Double click to collapse",
+ "collapse-hint": "Double click or press Space to collapse",
"set-limit": "Set limit...",
"set-limit-ok": "Set limit",
"limit-capacity": "Warn for exceeding the column capacity",
diff --git a/apps/client/src/widgets/collections/board/column.tsx b/apps/client/src/widgets/collections/board/column.tsx
index 8bf1f50ea9..6aaffb242d 100644
--- a/apps/client/src/widgets/collections/board/column.tsx
+++ b/apps/client/src/widgets/collections/board/column.tsx
@@ -518,9 +518,8 @@ export default function Column({
setColumnNameToEdit(column);
}
- // The other half of the toggle: the board's keyboard answers Space on a strip, which also
- // has to step focus onto the cards the column then draws. Only on the heading itself, the
- // buttons it carries answering Space for themselves.
+ // Space collapses the column; `keyboard.ts` handles it on a strip. The target check
+ // excludes the heading's buttons, which activate on Space themselves.
if (e.key === " " && !isCollapsed && e.target === e.currentTarget) {
e.preventDefault();
e.stopPropagation();
@@ -693,11 +692,11 @@ export default function Column({
<h3
ref={headerRef}
className={`${isEditing ? "editing" : ""}`}
- // While collapsed the header is what opens the column, so it says so and answers
- // for the keys a button answers for. Open, it is a heading again and claims
- // neither, `handleTitleKeyDown` taking the Space that collapses it.
+ // A collapsed header opens the column, so it is announced as a button. Open, it
+ // is a heading, and Space collapses it as a board shortcut like F2.
role={isCollapsed ? "button" : undefined}
aria-expanded={isCollapsed ? false : undefined}
+ aria-keyshortcuts="Space"
onContextMenu={openMenu}
onMouseDown={(e) => {
if (e.detail <= 1) {
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index bf944724a6..a184def521 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -386,11 +386,14 @@ describe("Collapsed board columns", () => {
expect(header()?.getAttribute("role")).toBe("button");
expect(header()?.getAttribute("aria-expanded")).toBe("false");
+ // The key is announced in both states.
+ expect(header()?.getAttribute("aria-keyshortcuts")).toBe("Space");
- // Open, it is a heading again: Space does nothing there, so no button is promised.
+ // Open, it is a heading again: Space is a board shortcut there, not a button press.
await select(mountPoint, 0);
expect(header()?.getAttribute("role")).toBeNull();
expect(header()?.getAttribute("aria-expanded")).toBeNull();
+ expect(header()?.getAttribute("aria-keyshortcuts")).toBe("Space");
// A column that was never collapsed says nothing either way.
expect(columnAt(mountPoint, 1).querySelector("h3")?.getAttribute("role")).toBeNull();
@@ -750,7 +753,7 @@ describe("Collapsed board columns", () => {
expect(isCollapsed(mountPoint, 1)).toBe(true);
expect(saved.at(-1)?.columns?.[1]).toEqual({ value: "Done", collapsed: true });
- // The reader is left on the strip's header, which is what opens the column again.
+ // The strip's header keeps the focus, so Space opens the column again.
const strip = columnAt(mountPoint, 1).querySelector("h3");
expect(document.activeElement).toBe(strip);
expect(strip?.getAttribute("aria-expanded")).toBe("false");
diff --git a/apps/client/src/widgets/collections/board/keyboard.spec.tsx b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
index a8f645ffcb..d834112db6 100644
--- a/apps/client/src/widgets/collections/board/keyboard.spec.tsx
+++ b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
@@ -503,7 +503,7 @@ describe("Board keyboard", () => {
expect(focusedName(board)).toBe("Third");
});
- /** Drawn as a strip in `index.spec.tsx`, where the harness reads the write back. */
+ /** This harness never reads the write back, so `index.spec.tsx` covers the strip. */
it("collapses an open column with Space instead of walking on", async () => {
const board = await renderBoard();
focusHeader(board, 1);
diff --git a/apps/client/src/widgets/collections/board/keyboard.ts b/apps/client/src/widgets/collections/board/keyboard.ts
index e93821931b..e2bb3e0228 100644
--- a/apps/client/src/widgets/collections/board/keyboard.ts
+++ b/apps/client/src/widgets/collections/board/keyboard.ts
@@ -288,8 +288,8 @@ export function useBoardKeyboard({
return;
}
- // Both keys, the collapsed header answering for a button and being announced as one. An
- // open column is collapsed by the header itself, which draws the collapse it asked for.
+ // Both keys, the collapsed header answering for a button and being announced as one.
+ // `column.tsx` handles Space on an open column, where the collapse is drawn faster.
if ((e.key === " " || e.key === "Enter") && spot.kind === "header") {
const column = columns[spot.column];
if (!columnsOf(container)[spot.column]?.classList.contains("collapsed")) return;
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html
index 43467d2429..5095081d1e 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Kanban Board.html
@@ -97,6 +97,8 @@
<li>To rename a column or a note, press F2 while it is focused.</li>
<li>To open a specific note or create a new item, press Enter while it is
focused.</li>
+ <li>To collapse or expand a column, press Space while its header is
+ focused.</li>
<li>To dismiss a rename of a note or a column, press Escape.</li>
</ul>
<h2>Configuration</h2>
diff --git a/docs/User Guide/User Guide/Collections/Kanban Board.md b/docs/User Guide/User Guide/Collections/Kanban Board.md
index 3730e0876b..ff718c319a 100644
--- a/docs/User Guide/User Guide/Collections/Kanban Board.md
+++ b/docs/User Guide/User Guide/Collections/Kanban Board.md
@@ -65,6 +65,7 @@ The board view has mild support for keyboard-based navigation:
* Use Tab and Shift+Tab to navigate between column titles, notes and the “New item” button for each of the columns, in sequential order.
* To rename a column or a note, press F2 while it is focused.
* To open a specific note or create a new item, press Enter while it is focused.
+* To collapse or expand a column, press Space while its header is focused.
* To dismiss a rename of a note or a column, press Escape.
## Configuration