Skip to content

Build your personal knowledge base with Trilium Notes

style/space usage: fix selection details button

Adorian Doran214efa4ede0d
diff --git a/apps/client/src/widgets/type_widgets/space_usage/browse.css b/apps/client/src/widgets/type_widgets/space_usage/browse.css
index 92067cb6bf..dbd7620b32 100644
--- a/apps/client/src/widgets/type_widgets/space_usage/browse.css
+++ b/apps/client/src/widgets/type_widgets/space_usage/browse.css
@@ -66,8 +66,9 @@
/* The way into the chosen child, for a reader who has not found the second tap that does the
same. Its line is held whether or not anything is chosen, so the chart above is laid out once
- and a tap on the ring never resizes it; one line always, the label being short enough that a
- narrow screen should cut it rather than fold the row open. */
+ and a tap on the ring never resizes it; the height comes from the control below, which stands
+ there hidden rather than absent. One line always: the label is short enough that a narrow
+ screen should cut it rather than fold the row open. */
.space-usage-browse-details {
display: flex;
flex: 0 0 auto;
@@ -75,26 +76,30 @@
align-items: center;
/* Clear of the strip below, whose own rule would otherwise sit right under the label. */
margin-bottom: 1.5em;
- /* The line it holds, at the leading stated below, plus the room around it. */
- min-height: calc(1.2em + 12px);
padding-block: 6px;
overflow: hidden;
- line-height: 1.2;
white-space: nowrap;
}
- /* The app's own quiet button, coloured to read as the link it stands for — the same colour the
- note's name wears in the middle of the chart. Everything else about it (its press, its focus,
- its theming) is the shared control's. */
+ /* Reads as the link it is, stripped the way the crumbs above are and wearing the colour the
+ note's name wears in the middle of the chart. No hover state: this line is only drawn where a
+ tap stands in for one, and there a hover is never anything but what the last tap left behind.
+ The block padding is the tap target, the row around it having none to give. */
.space-usage-details-link {
overflow: hidden;
+ border: none;
+ background: none;
+ padding: 6px 8px;
color: var(--link-color);
text-overflow: ellipsis;
white-space: nowrap;
+ cursor: pointer;
}
- .space-usage-details-link:hover {
- text-decoration: underline;
+ /* Nothing to open: it keeps its place in the layout and gives up everything else, the keyboard
+ and the accessibility tree included. */
+ .space-usage-details-link-idle {
+ visibility: hidden;
}
/* At the root there is nowhere to go back to: the arrow disappears but keeps its box, so the
diff --git a/apps/client/src/widgets/type_widgets/space_usage/browse.spec.tsx b/apps/client/src/widgets/type_widgets/space_usage/browse.spec.tsx
index 1d140f90e5..c9d6474428 100644
--- a/apps/client/src/widgets/type_widgets/space_usage/browse.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/space_usage/browse.spec.tsx
@@ -354,12 +354,17 @@ describe("Browse", () => {
probe.querySelector<HTMLElement>(".space-usage-details-link")?.click();
expect(open).toHaveBeenCalledTimes(1);
- // The line itself stays, holding the chart's layout still; only its label goes.
+ // With nothing to open it stands there hidden rather than leaving, so the chart above keeps
+ // the height it was laid out with.
render(null, probe);
const empty = renderSelectableBrowse({ markId: "revisions", label: "Revisions", size: 10 });
+ const idle = empty.querySelector(".space-usage-details-link");
- expect(empty.querySelector(".space-usage-browse-details")).not.toBeNull();
- expect(empty.querySelector(".space-usage-details-link")).toBeNull();
+ expect(idle).not.toBeNull();
+ expect(idle?.classList.contains("space-usage-details-link-idle")).toBe(true);
+
+ idle?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ expect(open).toHaveBeenCalledTimes(1);
});
it("hands the chosen mark to the donut, so the ring can draw it", () => {
diff --git a/apps/client/src/widgets/type_widgets/space_usage/browse.tsx b/apps/client/src/widgets/type_widgets/space_usage/browse.tsx
index 1aa48a613c..a5e39c9a33 100644
--- a/apps/client/src/widgets/type_widgets/space_usage/browse.tsx
+++ b/apps/client/src/widgets/type_widgets/space_usage/browse.tsx
@@ -1,6 +1,7 @@
import "./browse.css";
import type { SpaceUsageNoteResponse } from "@triliumnext/commons";
+import clsx from "clsx";
import { Fragment } from "preact";
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
@@ -8,7 +9,6 @@ import froca from "../../../services/froca";
import { t } from "../../../services/i18n";
import { formatSize } from "../../../services/utils";
import ActionButton from "../../react/ActionButton";
-import Button from "../../react/Button";
import type { DonutRing, DonutSegment } from "../../react/charts/DonutChart";
import { useFetch } from "../../react/use_fetch";
import { type ContentChangedHandler, openSpaceUsageContextMenu } from "./context_menu";
@@ -182,15 +182,19 @@ export default function Browse({
and leaving would resize the chart above it at every tap. */}
{onSelect && (
<div className="space-usage-browse-details">
- {selection?.onOpen && (
- <Button
- className="space-usage-details-link"
- kind="lowProfile"
- size="small"
- text={t("space_usage.show_selection_details")}
- onClick={selection.onOpen}
- />
- )}
+ {/* Drawn whatever is chosen and merely hidden where there is nothing to open, so
+ the line it stands on is the height of the control itself rather than a
+ guess at it. Hidden this way it is also out of reach of the keyboard and of
+ assistive technology, which `display: none` and a bare gap both cost.
+
+ A plain button, as the breadcrumb's own crumbs are: the shared control's
+ low-profile look loses to the app's global `.btn` surface, and this reads as
+ a link rather than as a control anyway. */}
+ <button
+ type="button"
+ className={clsx("space-usage-details-link", !selection?.onOpen && "space-usage-details-link-idle")}
+ onClick={() => selection?.onOpen?.()}
+ >{t("space_usage.show_selection_details")}</button>
</div>
)}
</div>