From b5f73874cbf51e2c24f6bfd466f12be114634554 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 8 Oct 2025 19:06:19 +0300 Subject: [PATCH] fix(client/rtl): tooltips not inverted --- apps/client/src/services/utils.ts | 12 ++++++++++++ apps/client/src/widgets/buttons/abstract_button.ts | 6 ++++-- .../src/widgets/buttons/right_dropdown_button.ts | 5 +++-- apps/client/src/widgets/quick_search.ts | 4 ++-- apps/client/src/widgets/react/FormList.tsx | 10 +++++----- apps/client/src/widgets/sync_status.ts | 6 +++--- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts index 3c83d3e86..0f17bdc79 100644 --- a/apps/client/src/services/utils.ts +++ b/apps/client/src/services/utils.ts @@ -869,6 +869,18 @@ export function getErrorMessage(e: unknown) { } } +/** + * Handles left or right placement of e.g. tooltips in case of right-to-left languages. If the current language is a RTL one, then left and right are swapped. Other directions are unaffected. + * @param placement a string optionally containing a "left" or "right" value. + * @returns a left/right value swapped if needed, or the same as input otherwise. + */ +export function handleRightToLeftPlacement(placement: T) { + if (!glob.isRtl) return placement; + if (placement === "left") return "right"; + if (placement === "right") return "left"; + return placement; +} + export default { reloadFrontendApp, restartDesktopApp, diff --git a/apps/client/src/widgets/buttons/abstract_button.ts b/apps/client/src/widgets/buttons/abstract_button.ts index 7e0923b41..308009fa6 100644 --- a/apps/client/src/widgets/buttons/abstract_button.ts +++ b/apps/client/src/widgets/buttons/abstract_button.ts @@ -1,5 +1,6 @@ import { Tooltip } from "bootstrap"; import NoteContextAwareWidget from "../note_context_aware_widget.js"; +import { handleRightToLeftPlacement } from "../../services/utils.js"; const TPL = /*html*/`