Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile/nav): display previous note in the back arrow

Elian Doran17fdbf026232
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css
index 7faa4bcd5c..834406a534 100644
--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css
+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css
@@ -15,15 +15,43 @@
}
.mobile-navigator-back {
- font-size: 1.6em;
- min-width: 40px;
+ display: flex;
+ align-items: center;
+ gap: 4px;
min-height: 40px;
+ padding: 6px 10px 6px 4px;
+ background: none;
+ border: none;
+ color: var(--main-text-color);
+ font-size: 1em;
+ font-weight: 500;
+ cursor: pointer;
+ -webkit-tap-highlight-color: transparent;
+ max-width: 100%;
+}
+
+.mobile-navigator-back:disabled {
+ cursor: default;
+ opacity: 0.6;
}
.mobile-navigator-back.invisible {
visibility: hidden;
}
+.mobile-navigator-back-icon {
+ flex: 0 0 auto;
+ font-size: 1.5em;
+}
+
+.mobile-navigator-back-title {
+ flex: 1 1 auto;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ text-align: start;
+}
+
.mobile-navigator-scroll {
position: relative;
flex: 1 1 auto;
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx
index 635ca8a4e3..97639d7785 100644
--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx
+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx
@@ -7,7 +7,6 @@ import type FNote from "../../entities/fnote";
import froca from "../../services/froca";
import { t } from "../../services/i18n";
import { NoteContent } from "../collections/legacy/ListOrGridView";
-import ActionButton from "../react/ActionButton";
import {
useActiveNoteContext,
useNote,
@@ -90,6 +89,8 @@ export default function MobileNoteNavigator() {
const isLoaded = !!currentParentId && loadedParents.has(currentParentId);
const children = useNavigatorChildren(parentNote, hideArchived, isLoaded);
const canGoBack = stack.length > 1;
+ const backTargetId = canGoBack ? getLastSegment(stack[stack.length - 2]) : undefined;
+ const backTargetNote = useNote(backTargetId);
// Gate the visible body on the content preview being ready to avoid a layout shift
// when the preview finishes rendering. Tied to the parent's noteId so a stale "ready"
@@ -191,13 +192,21 @@ export default function MobileNoteNavigator() {
return (
<div className="mobile-note-navigator">
<div className="mobile-navigator-toolbar">
- <ActionButton
+ <button
+ type="button"
className={clsx("mobile-navigator-back", !canGoBack && "invisible")}
- icon={pendingPop ? "bx bx-loader bx-spin" : "bx bx-chevron-left"}
- text={t("mobile_note_navigator.back")}
onClick={canGoBack && !pendingPop ? goBack : undefined}
disabled={!canGoBack || pendingPop}
- />
+ aria-label={t("mobile_note_navigator.back")}
+ >
+ <Icon
+ icon={pendingPop ? "bx bx-loader bx-spin" : "bx bx-chevron-left"}
+ className="mobile-navigator-back-icon"
+ />
+ <span className="mobile-navigator-back-title">
+ {backTargetNote?.title ?? ""}
+ </span>
+ </button>
</div>
<div ref={scrollRef} className={clsx("mobile-navigator-scroll", showInitialLoader && "is-pending")}>