From 476c1620163b30ce906090cc43b330c08a818b3b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 13 Dec 2025 16:31:19 +0200 Subject: [PATCH] fix(layout/formatting_toolbar): memory leak for closed tabs --- apps/client/src/widgets/ribbon/FormattingToolbar.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/client/src/widgets/ribbon/FormattingToolbar.tsx b/apps/client/src/widgets/ribbon/FormattingToolbar.tsx index c1e7d103f..c8d32aab7 100644 --- a/apps/client/src/widgets/ribbon/FormattingToolbar.tsx +++ b/apps/client/src/widgets/ribbon/FormattingToolbar.tsx @@ -64,6 +64,13 @@ export function FixedFormattingToolbar() { } }); + // Clean the cache when tabs are closed. + useTriliumEvent("noteContextRemoved", ({ ntxIds: eventNtxIds }) => { + for (const eventNtxId of eventNtxIds) { + toolbarCache.delete(eventNtxId); + } + }); + // Switch between the cached toolbar when user navigates to a different note context. useEffect(() => { if (!ntxId) return;