Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile/nav): hoisted badge indicator

Elian Doran4b40adaf6221
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css
index 6865a435fc..3f13b79412 100644
--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css
+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css
@@ -9,11 +9,42 @@
.mobile-navigator-toolbar {
display: flex;
align-items: center;
+ gap: 8px;
padding: 4px 6px;
border-bottom: 1px solid var(--main-border-color);
background: var(--main-background-color);
}
+.mobile-navigator-hoisted-badge {
+ flex: 0 1 auto;
+ min-width: 0;
+ margin-inline-start: auto;
+ margin-inline-end: 4px;
+ --badge-radius: 12px;
+ --color: var(--input-background-color);
+ color: var(--main-text-color);
+}
+
+.mobile-navigator-hoisted-badge .text {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ min-width: 0;
+}
+
+.mobile-navigator-hoisted-title {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.mobile-navigator-hoisted-close {
+ flex: 0 0 auto;
+ font-size: 1.3em;
+ opacity: 0.6;
+}
+
.mobile-navigator-back {
display: flex;
align-items: center;
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx
index b5cf86f6bd..cdcc5b5f28 100644
--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx
+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx
@@ -7,16 +7,20 @@ import type Component from "../../components/component";
import type FNote from "../../entities/fnote";
import contextMenu from "../../menus/context_menu";
import { buildTreeContextMenuItems, handleTreeContextMenuSelect } from "../../menus/tree_context_menu";
+import { getReadableTextColor } from "../../services/css_class_manager";
import froca from "../../services/froca";
+import hoisted_note from "../../services/hoisted_note";
import { t } from "../../services/i18n";
import utils from "../../services/utils";
import { NoteContent } from "../collections/legacy/ListOrGridView";
+import { Badge } from "../react/Badge";
import {
useActiveNoteContext,
useLongPressContextMenu,
useNote,
useNoteColorClass,
useNoteIcon,
+ useNoteLabel,
useNoteLabelBoolean,
useNoteTitle,
useTriliumEvent,
@@ -232,6 +236,7 @@ export default function MobileNoteNavigator() {
{backTargetTitle ?? ""}
</span>
</button>
+ <HoistedNoteBadge hoistedNoteId={effectiveHoistedId} />
</div>
<div ref={scrollRef} className={clsx("mobile-navigator-scroll", showInitialLoader && "is-pending")}>
@@ -318,6 +323,40 @@ export default function MobileNoteNavigator() {
);
}
+/**
+ * Hoisted-note badge (mirrors Breadcrumb.tsx): only shown when hoisted below
+ * root; click anywhere on the badge (including the X) to unhoist. Respects
+ * workspace icon/color overrides.
+ */
+function HoistedNoteBadge({ hoistedNoteId }: { hoistedNoteId: string }) {
+ const isHoisted = hoistedNoteId !== "root";
+ const hoistedNote = useNote(isHoisted ? hoistedNoteId : undefined);
+ const hoistedNoteIcon = useNoteIcon(hoistedNote);
+ const hoistedTitle = useNoteTitle(isHoisted ? hoistedNoteId : undefined, undefined);
+ const [isWorkspace] = useNoteLabelBoolean(hoistedNote, "workspace");
+ const [workspaceIconClass] = useNoteLabel(hoistedNote, "workspaceIconClass");
+ const [workspaceColor] = useNoteLabel(hoistedNote, "workspaceTabBackgroundColor");
+
+ if (!isHoisted || !hoistedNote) return null;
+
+ return (
+ <Badge
+ className="mobile-navigator-hoisted-badge"
+ icon={isWorkspace ? (workspaceIconClass || hoistedNoteIcon) : "bx bxs-chevrons-up"}
+ text={<>
+ <span className="mobile-navigator-hoisted-title">{hoistedTitle ?? hoistedNote.title}</span>
+ <Icon icon="bx bx-x" className="mobile-navigator-hoisted-close" />
+ </>}
+ tooltip={t("breadcrumb.hoisted_badge_title")}
+ onClick={() => hoisted_note.unhoist()}
+ style={workspaceColor ? {
+ "--color": workspaceColor,
+ "color": getReadableTextColor(workspaceColor)
+ } as Record<string, string> : undefined}
+ />
+ );
+}
+
interface NavigatorRowProps {
note: FNote;
parentNoteId: string | undefined;