From 1ab89d0db024e436c9dc80f55b2aeacbd41be727 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 10 Dec 2025 23:36:47 +0200 Subject: [PATCH] fix(status_bar): language selector not updating properly --- apps/client/src/widgets/NoteStatusBar.tsx | 22 ++++++++++++------- .../src/widgets/ribbon/BasicPropertiesTab.tsx | 2 +- .../options/components/LocaleSelector.tsx | 8 +++---- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apps/client/src/widgets/NoteStatusBar.tsx b/apps/client/src/widgets/NoteStatusBar.tsx index 9255fb8fd..3b686ff84 100644 --- a/apps/client/src/widgets/NoteStatusBar.tsx +++ b/apps/client/src/widgets/NoteStatusBar.tsx @@ -1,19 +1,25 @@ +import "./NoteStatusBar.css"; + import { t } from "../services/i18n"; import { openInAppHelpFromUrl } from "../services/utils"; -import "./NoteStatusBar.css"; import { FormListItem } from "./react/FormList"; - +import { useNoteContext } from "./react/hooks"; import { NoteLanguageSelector } from "./ribbon/BasicPropertiesTab"; export default function NoteStatusBar() { + const { note } = useNoteContext(); + return (
- openInAppHelpFromUrl("veGu4faJErEM")} - icon="bx bx-help-circle" - >{t("note_language.help-on-languages")} - )} /> + openInAppHelpFromUrl("veGu4faJErEM")} + icon="bx bx-help-circle" + >{t("note_language.help-on-languages")} + )} + />
); } diff --git a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx index 04e8334ee..479994ca3 100644 --- a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx +++ b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx @@ -330,7 +330,7 @@ function NoteLanguageSwitch({ note }: { note?: FNote | null }) { ); } -export function NoteLanguageSelector({ note, extraChildren }: { note?: FNote | null, extraChildren?: ComponentChildren }) { +export function NoteLanguageSelector({ note, extraChildren }: { note: FNote | null | undefined, extraChildren?: ComponentChildren }) { const [ modalShown, setModalShown ] = useState(false); const [ languages ] = useTriliumOption("languages"); const DEFAULT_LOCALE = { diff --git a/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx b/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx index 5628cc798..b9b1d8758 100644 --- a/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx +++ b/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx @@ -1,8 +1,9 @@ import { Locale } from "@triliumnext/commons"; +import { ComponentChildren } from "preact"; +import { useMemo } from "preact/hooks"; + import Dropdown from "../../../react/Dropdown"; import { FormDropdownDivider, FormListItem } from "../../../react/FormList"; -import { ComponentChildren } from "preact"; -import { useMemo, useState } from "preact/hooks"; export function LocaleSelector({ id, locales, currentValue, onChange, defaultLocale, extraChildren }: { id?: string; @@ -12,7 +13,7 @@ export function LocaleSelector({ id, locales, currentValue, onChange, defaultLoc defaultLocale?: Locale, extraChildren?: ComponentChildren }) { - const [ activeLocale, setActiveLocale ] = useState(defaultLocale?.id === currentValue ? defaultLocale : locales.find(l => l.id === currentValue)); + const activeLocale = defaultLocale?.id === currentValue ? defaultLocale : locales.find(l => l.id === currentValue); const processedLocales = useMemo(() => { const leftToRightLanguages = locales.filter((l) => !l.rtl); @@ -48,7 +49,6 @@ export function LocaleSelector({ id, locales, currentValue, onChange, defaultLoc rtl={locale.rtl} checked={locale.id === currentValue} onClick={() => { - setActiveLocale(locale); onChange(locale.id); }} >{locale.name}