Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(mobile): mirror the tree's chevrons in right-to-left languages
Elian Doran6cc0983b5473
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.spec.tsx b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.spec.tsxindex 2890a091a9..cc8712f1a7 100644--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.spec.tsx+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.spec.tsx@@ -12,7 +12,7 @@ import search from "../../services/search";import { buildNote, buildNotes } from "../../test/easy-froca";import { renderInto } from "../../test/render";import { ParentComponent } from "../react/react_utils";-import { BookmarkList, getListedChildCount, getPreviewNoteIds, PreviewSlot, TitleWithIndicators, UnhoistButton, WorkspaceCards } from "./MobileNoteNavigator";+import { BookmarkList, getChevronIcon, getListedChildCount, getPreviewNoteIds, PreviewSlot, TitleWithIndicators, UnhoistButton, WorkspaceCards } from "./MobileNoteNavigator";vi.mock("../../services/i18n", () => ({t: (key: string, options?: object) => (options ? `${key} ${JSON.stringify(options)}` : key),@@ -56,6 +56,20 @@ describe("getListedChildCount", () => {});});+describe("getChevronIcon", () => {+ it("points back toward the leading edge and forward toward the trailing one", () => {+ const { isRtl } = glob;+ try {+ glob.isRtl = false;+ expect([ getChevronIcon("back"), getChevronIcon("forward") ]).toEqual([ "bx bx-chevron-left", "bx bx-chevron-right" ]);+ glob.isRtl = true;+ expect([ getChevronIcon("back"), getChevronIcon("forward") ]).toEqual([ "bx bx-chevron-right", "bx bx-chevron-left" ]);+ } finally {+ glob.isRtl = isRtl;+ }+ });+});+describe("getPreviewNoteIds", () => {it("keeps the previews of the columns shown last, and the one about to be shown", () => {expect(getPreviewNoteIds([], "a")).toEqual([ "a" ]);diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsxindex 056ff5b5cf..7cce4a0550 100644--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx@@ -263,7 +263,7 @@ export default function MobileNoteNavigator() {aria-label={t("mobile_note_navigator.back")}><Icon- icon={pendingPop ? "bx bx-loader bx-spin" : "bx bx-chevron-left"}+ icon={pendingPop ? "bx bx-loader bx-spin" : getChevronIcon("back")}className="mobile-navigator-back-icon"/><span className="mobile-navigator-back-title">@@ -662,7 +662,7 @@ function NavigatorRow({ note, parentNoteId, childNotePath, isActive, isPending,{isPending ? (<Icon icon="bx bx-loader bx-spin" className="mobile-navigator-row-chevron" />) : hasChildren ? (- <Icon icon="bx bx-chevron-right" className="mobile-navigator-row-chevron" />+ <Icon icon={getChevronIcon("forward")} className="mobile-navigator-row-chevron" />) : null}</div>);@@ -828,3 +828,12 @@ function buildNoteContextMenu(notePath: string, parentComponent: Component | nul});};}++/**+ * The chevron pointing `back` toward the leading edge of the reading direction, or `forward`+ * toward the trailing one.+ */+export function getChevronIcon(direction: "back" | "forward") {+ const pointsLeft = (direction === "back") !== !!glob.isRtl;+ return pointsLeft ? "bx bx-chevron-left" : "bx bx-chevron-right";+}