From 17eeac75cd9fcd8dd79b6a936267f0395ea5e488 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 3 Mar 2026 19:29:32 +0100 Subject: [PATCH] fix: open newly created theme in editor after New Theme command After createTheme(), the theme file was created and the sidebar navigated to the Theme section, but the note was never opened in the editor. Now captures the returned path and opens it via handleSelectNote. Co-Authored-By: Claude Opus 4.6 --- src/App.tsx | 8 ++++++-- src/hooks/useVaultLoader.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 6cb7dee3..ba2010aa 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -330,9 +330,13 @@ function App() { themes: themeManager.themes, activeThemeId: themeManager.activeThemeId, onSwitchTheme: themeManager.switchTheme, onCreateTheme: async () => { - await themeManager.createTheme() - await vault.reloadVault() + const path = await themeManager.createTheme() + const freshEntries = await vault.reloadVault() setSelection({ kind: 'sectionGroup', type: 'Theme' }) + if (path) { + const entry = freshEntries.find(e => e.path === path) + if (entry) notes.handleSelectNote(entry) + } }, onOpenTheme: (themeId: string) => { const entry = vault.entries.find(e => e.path === themeId) diff --git a/src/hooks/useVaultLoader.ts b/src/hooks/useVaultLoader.ts index 1f3da296..3efe955c 100644 --- a/src/hooks/useVaultLoader.ts +++ b/src/hooks/useVaultLoader.ts @@ -172,8 +172,8 @@ export function useVaultLoader(vaultPath: string) { const reloadVault = useCallback( () => loadVaultData(vaultPath) - .then((data) => { setEntries(data.entries); setAllContent((prev) => ({ ...prev, ...data.allContent })); loadModifiedFiles() }) - .catch((err) => console.warn('Vault reload failed:', err)), + .then((data) => { setEntries(data.entries); setAllContent((prev) => ({ ...prev, ...data.allContent })); loadModifiedFiles(); return data.entries }) + .catch((err) => { console.warn('Vault reload failed:', err); return [] as VaultEntry[] }), [vaultPath, loadModifiedFiles], )