From 5784360b0110de30abdc23efb7b0941fcac348db Mon Sep 17 00:00:00 2001 From: Arash Ari Sheyda Date: Tue, 24 Mar 2026 18:59:00 -0600 Subject: [PATCH] fix: guard against undefined commandShortcuts when saving shortcuts --- .../components/views-builtin/SettingsShortcuts.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/client/webcomponents/components/views-builtin/SettingsShortcuts.vue b/packages/core/src/client/webcomponents/components/views-builtin/SettingsShortcuts.vue index eff7c0e7..59adf24a 100644 --- a/packages/core/src/client/webcomponents/components/views-builtin/SettingsShortcuts.vue +++ b/packages/core/src/client/webcomponents/components/views-builtin/SettingsShortcuts.vue @@ -60,13 +60,16 @@ function isOverridden(id: string): boolean { function clearShortcut(commandId: string) { commandsCtx.settings.mutate((state) => { + if (!state.commandShortcuts) + state.commandShortcuts = {} state.commandShortcuts[commandId] = [] }) } function resetShortcut(commandId: string) { commandsCtx.settings.mutate((state) => { - delete state.commandShortcuts[commandId] + if (state.commandShortcuts) + delete state.commandShortcuts[commandId] }) } @@ -188,6 +191,8 @@ function saveEditor() { if (!editorCommandId.value || !editorCanSave.value) return commandsCtx.settings.mutate((state) => { + if (!state.commandShortcuts) + state.commandShortcuts = {} state.commandShortcuts[editorCommandId.value!] = [{ key: editorComposedKey.value }] }) closeEditor()