fix(ui): escaping theme dialog no longer resets theme to default (#11323)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Pyush Sinha
2025-10-20 10:50:09 -07:00
committed by GitHub
parent d0ab6e9982
commit 397e52dac7
6 changed files with 51 additions and 14 deletions

View File

@@ -13,10 +13,8 @@ import process from 'node:process';
interface UseThemeCommandReturn {
isThemeDialogOpen: boolean;
openThemeDialog: () => void;
handleThemeSelect: (
themeName: string | undefined,
scope: SettingScope,
) => void; // Added scope
closeThemeDialog: () => void;
handleThemeSelect: (themeName: string, scope: SettingScope) => void;
handleThemeHighlight: (themeName: string | undefined) => void;
}
@@ -63,8 +61,14 @@ export const useThemeCommand = (
[applyTheme],
);
const closeThemeDialog = useCallback(() => {
// Re-apply the saved theme to revert any preview changes from highlighting
applyTheme(loadedSettings.merged.ui?.theme);
setIsThemeDialogOpen(false);
}, [applyTheme, loadedSettings]);
const handleThemeSelect = useCallback(
(themeName: string | undefined, scope: SettingScope) => {
(themeName: string, scope: SettingScope) => {
try {
// Merge user and workspace custom themes (workspace takes precedence)
const mergedCustomThemes = {
@@ -95,6 +99,7 @@ export const useThemeCommand = (
return {
isThemeDialogOpen,
openThemeDialog,
closeThemeDialog,
handleThemeSelect,
handleThemeHighlight,
};