Skip to content

Commit db6f02f

Browse files
antfubotSaKaNa-Y
andcommitted
fix(hub-ui): keep transient-context commands listed in shortcut settings
Pin `dockOpen`/`paletteOpen` when filtering commands for the shortcut settings list, instead of evaluating `when` against the live context. Those two flags are transient dispatch state (close-panel's `!paletteOpen` exists to hand Escape to the palette, not to mark the command unbindable), so filtering by their live values dropped permanently bindable rows like Close Panel the moment the command palette opened. Ports vitejs/devtools#524 by @SaKaNa-Y to this fork's equivalent file after the v0.9 migration. Co-authored-by: SaKaNa-Y <15715093608@163.com>
1 parent e6a2cab commit db6f02f

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

packages/hub-ui/src/client/components/views-builtin/SettingsShortcuts.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ interface ShortcutRow {
2222
indent: boolean
2323
}
2424
25-
// Only offer to bind commands that are actually reachable right now — binding a
26-
// key to something the current context rules out (e.g. the dock-mode commands
27-
// while the dock is detached into a popup) would silently do nothing.
28-
const availableCommands = computed(() => filterCommandsByWhen(commandsCtx.commands, props.context.when.context))
25+
// This page is only reachable with the dock open and the palette closed, so `when`
26+
// is evaluated against that context rather than the live one. `dockOpen`/`paletteOpen`
27+
// are transient dispatch state — `close-panel`'s `!paletteOpen` exists to hand Escape
28+
// to the palette, not to say the command is unbindable — so filtering by them would
29+
// drop permanently bindable rows the moment Ctrl+K is pressed. `popupOpen` and
30+
// `clientType` stay live: those describe whether a command can exist at all, which is
31+
// why the dock-mode commands still vanish while the dock is detached into a popup.
32+
const availableCommands = computed(() => filterCommandsByWhen(
33+
commandsCtx.commands,
34+
{ ...props.context.when.context, dockOpen: true, paletteOpen: false },
35+
))
2936
3037
const shortcutRows = computed<ShortcutRow[]>(() => {
3138
const rows: ShortcutRow[] = []

0 commit comments

Comments
 (0)