Skip to content

Build your personal knowledge base with Trilium Notes

client: fix some issues

Adorian Doran19a9370027ce
diff --git a/apps/client/src/widgets/bulk_actions/note/save_revision.tsx b/apps/client/src/widgets/bulk_actions/note/save_revision.tsx
index 6fad78af44..51aafd10a3 100644
--- a/apps/client/src/widgets/bulk_actions/note/save_revision.tsx
+++ b/apps/client/src/widgets/bulk_actions/note/save_revision.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "preact/hooks";
+import { useState } from "preact/hooks";
import { t } from "../../../services/i18n.js";
import FormTextBox from "../../react/FormTextBox.jsx";
import { useSpacedUpdate } from "../../react/hooks.jsx";
@@ -9,7 +9,14 @@ import BulkAction from "../BulkAction.jsx";
function SaveRevisionBulkActionComponent({ bulkAction, actionDef }: { bulkAction: AbstractBulkAction, actionDef: ActionDefinition }) {
const [ revisionName, setRevisionName ] = useState<string>(actionDef.revisionName ?? "");
const spacedUpdate = useSpacedUpdate(() => bulkAction.saveAction({ revisionName }));
- useEffect(() => spacedUpdate.scheduleUpdate(), [ revisionName ]);
+
+ function onChange(value: string) {
+ setRevisionName(value);
+ // Mirror into actionDef immediately so an Execute that fires before the debounced
+ // saveAction still submits the typed name rather than a stale/undefined value.
+ bulkAction.actionDef.revisionName = value;
+ spacedUpdate.scheduleUpdate();
+ }
return (
<BulkAction
@@ -19,10 +26,10 @@ function SaveRevisionBulkActionComponent({ bulkAction, actionDef }: { bulkAction
>
<FormTextBox
placeholder={t("save_revision.revision_name_placeholder")}
- currentValue={revisionName} onChange={setRevisionName}
+ currentValue={revisionName} onChange={onChange}
/>
</BulkAction>
- )
+ );
}
export default class SaveRevisionBulkAction extends AbstractBulkAction {
@@ -35,6 +42,6 @@ export default class SaveRevisionBulkAction extends AbstractBulkAction {
}
doRender() {
- return <SaveRevisionBulkActionComponent bulkAction={this} actionDef={this.actionDef} />
+ return <SaveRevisionBulkActionComponent bulkAction={this} actionDef={this.actionDef} />;
}
}
diff --git a/apps/client/src/widgets/launch_bar/ColorSchemeSwitcher.tsx b/apps/client/src/widgets/launch_bar/ColorSchemeSwitcher.tsx
index c8b42ea3d0..56f9bc7748 100644
--- a/apps/client/src/widgets/launch_bar/ColorSchemeSwitcher.tsx
+++ b/apps/client/src/widgets/launch_bar/ColorSchemeSwitcher.tsx
@@ -11,19 +11,20 @@ const SCHEME_ICONS: Record<ColorScheme, string> = {
dark: "bx bx-moon"
};
-const SCHEME_LABELS: Record<ColorScheme, string> = {
- system: t("theme.color_scheme_switcher_system"),
- light: t("theme.color_scheme_switcher_light"),
- dark: t("theme.color_scheme_switcher_dark")
-};
-
export default function ColorSchemeSwitcher({ launcherNote }: LauncherNoteProps) {
const [ theme, setTheme ] = useTriliumOption("theme");
const { scheme, isCustom } = resolveColorScheme(theme);
+ // Resolved at render time (not module load) so the labels follow a runtime language change.
+ const schemeLabels: Record<ColorScheme, string> = {
+ system: t("theme.color_scheme_switcher_system"),
+ light: t("theme.color_scheme_switcher_light"),
+ dark: t("theme.color_scheme_switcher_dark")
+ };
+
const tooltip = isCustom
? t("theme.color_scheme_switcher_unsupported")
- : `<span class="mode">${SCHEME_LABELS[scheme]}</span><span class="hint">${t("theme.color_scheme_switcher_hint")}</span>`;
+ : `<span class="mode">${schemeLabels[scheme]}</span><span class="hint">${t("theme.color_scheme_switcher_hint")}</span>`;
return (
<LaunchBarActionButton
diff --git a/apps/client/src/widgets/react/ActionButton.tsx b/apps/client/src/widgets/react/ActionButton.tsx
index 1e3129ae47..b6882a5342 100644
--- a/apps/client/src/widgets/react/ActionButton.tsx
+++ b/apps/client/src/widgets/react/ActionButton.tsx
@@ -32,26 +32,27 @@ export default function ActionButton({ text, icon, className, triggerCommand, ti
const title = keyboardShortcut?.length ? `${text} (${keyboardShortcut.join(",")})` : text;
const titleRef = useRef(title);
titleRef.current = title;
- const hasTitle = title.length > 0;
+ const hasTitle = !!title && title.length > 0;
// The tooltip is recreated only when its structural options (or its presence) change — not when
// the label text changes. A plain text change is pushed into the live tooltip via setContent
// below, so a dynamic label updates in place instead of disposing and recreating the tooltip,
- // which would drop the current hover.
+ // which would drop the current hover. The title is resolved lazily (a function) so Bootstrap
+ // always reads the latest value from titleRef rather than one captured when the config was memoized.
const tooltipConfig = useMemo<Partial<Tooltip.Options>>(() => ({
- title: hasTitle ? titleRef.current : undefined,
+ title: hasTitle ? () => titleRef.current ?? "" : undefined,
placement: titlePosition ?? "bottom",
fallbackPlacements: [ titlePosition ?? "bottom" ],
customClass: tooltipClass ?? "",
html: tooltipHtml ?? false,
- trigger: cachedIsMobile ? "focus" : "hover",
+ trigger: cachedIsMobile ? "focus" : "hover focus",
animation: false
}), [titlePosition, tooltipClass, tooltipHtml, hasTitle]);
useStaticTooltip(buttonRef, tooltipConfig);
useEffect(() => {
if (buttonRef.current) {
- Tooltip.getInstance(buttonRef.current)?.setContent({ ".tooltip-inner": title });
+ Tooltip.getInstance(buttonRef.current)?.setContent({ ".tooltip-inner": title ?? "" });
}
}, [title]);
diff --git a/packages/trilium-core/src/services/hidden_subtree_launcherbar.ts b/packages/trilium-core/src/services/hidden_subtree_launcherbar.ts
index 97724d64ac..e1b1810afc 100644
--- a/packages/trilium-core/src/services/hidden_subtree_launcherbar.ts
+++ b/packages/trilium-core/src/services/hidden_subtree_launcherbar.ts
@@ -98,8 +98,7 @@ export default function buildLaunchBarConfig() {
type: "launcher",
builtinWidget: "sidebarChat",
icon: "bx bx-message-square-dots"
- },
-
+ }
];
const desktopVisibleLaunchers: HiddenSubtreeItem[] = [