From 1ff894fa50f83a6d280246f48bce25c292e071c7 Mon Sep 17 00:00:00 2001 From: vihar Date: Wed, 23 Sep 2026 21:38:38 +0530 Subject: [PATCH 1/5] fix(power-k): shortcut matching, badge rendering, sequence buffer, Cmd+K toggle - Map shifted punctuation (`<`, `"`) back to its base key so registered `cmd+shift+,` / `cmd+shift+'` shortcuts (Copy URL, Copy title) actually fire - Render one keycap per shortcut part instead of splitting the joined label per character, which showed `Ctrl` as four keys on Windows/Linux - Ignore auto-repeat, reset the key-sequence buffer on non-printable keys, and restart it when the buffer can no longer match a registered sequence, so a stray key or Escape no longer blocks shortcuts for the next second - Stop Cmd+K propagation inside the palette so it closes instead of being re-opened by the document-level handler - Replace deprecated navigator.platform with a userAgent check; use data-dependent keys for the rendered keycaps --- .../core/components/power-k/core/registry.ts | 6 ++ .../power-k/core/shortcut-handler.ts | 53 ++++++++++++++++- .../ui/modal/command-item-shortcut-badge.tsx | 59 +++++++++---------- .../components/power-k/ui/modal/wrapper.tsx | 3 + 4 files changed, 88 insertions(+), 33 deletions(-) diff --git a/apps/web/core/components/power-k/core/registry.ts b/apps/web/core/components/power-k/core/registry.ts index 08ed75a9f25..9fd273ff92d 100644 --- a/apps/web/core/components/power-k/core/registry.ts +++ b/apps/web/core/components/power-k/core/registry.ts @@ -27,6 +27,7 @@ export interface IPowerKCommandRegistry { findByShortcut(ctx: TPowerKContext, key: string): TPowerKCommandConfig | undefined; findByKeySequence(ctx: TPowerKContext, sequence: string): TPowerKCommandConfig | undefined; findByModifierShortcut(ctx: TPowerKContext, shortcut: string): TPowerKCommandConfig | undefined; + hasKeySequencePrefix(ctx: TPowerKContext, prefix: string): boolean; // Utility clear(): void; } @@ -131,6 +132,11 @@ export class PowerKCommandRegistry implements IPowerKCommandRegistry { return commandId ? this.commands.get(commandId) : undefined; }); + hasKeySequencePrefix: IPowerKCommandRegistry["hasKeySequencePrefix"] = (ctx, prefix) => { + const normalizedPrefix = prefix.toLowerCase(); + return Array.from(this.getKeySequenceMap(ctx).keys()).some((sequence) => sequence.startsWith(normalizedPrefix)); + }; + // ============================================================================ // Utility // ============================================================================ diff --git a/apps/web/core/components/power-k/core/shortcut-handler.ts b/apps/web/core/components/power-k/core/shortcut-handler.ts index 85bcb27a103..6aa05ace8a3 100644 --- a/apps/web/core/components/power-k/core/shortcut-handler.ts +++ b/apps/web/core/components/power-k/core/shortcut-handler.ts @@ -7,6 +7,35 @@ import type { IPowerKCommandRegistry } from "./registry"; import type { TPowerKCommandConfig, TPowerKContext } from "./types"; +/** + * With Shift held, `e.key` reports the shifted glyph on US-style layouts + * ("<" for ","). Map it back to the base character so it matches the + * registered form ("cmd+shift+,"). Letters are unaffected. + */ +const SHIFTED_KEY_TO_BASE: Record = { + "<": ",", + ">": ".", + "?": "/", + ":": ";", + '"': "'", + "~": "`", + "{": "[", + "}": "]", + "|": "\\", + _: "-", + "+": "=", + "!": "1", + "@": "2", + "#": "3", + $: "4", + "%": "5", + "^": "6", + "&": "7", + "*": "8", + "(": "9", + ")": "0", +}; + /** * Formats a keyboard event into a modifier shortcut string * e.g., "cmd+k", "cmd+shift+,", "cmd+delete" @@ -18,7 +47,8 @@ export function formatModifierShortcut(e: KeyboardEvent): string { if (e.altKey) parts.push("alt"); if (e.shiftKey) parts.push("shift"); - const key = e.key.toLowerCase(); + let key = e.key.toLowerCase(); + if (e.shiftKey && e.key.length === 1) key = SHIFTED_KEY_TO_BASE[e.key] ?? key; parts.push(key === " " ? "space" : key); return parts.join("+"); @@ -71,6 +101,9 @@ export class ShortcutHandler { handleKeyDown = (e: KeyboardEvent): void => { if (!this.isEnabled) return; + // Auto-repeat must neither re-fire a shortcut nor touch the sequence buffer + if (e.repeat) return; + const key = e.key.toLowerCase(); const hasModifier = e.metaKey || e.ctrlKey || e.altKey || e.shiftKey; @@ -113,11 +146,19 @@ export class ShortcutHandler { * Handle single key shortcuts or build sequences (c, gm, op, etc.) */ private handleKeyOrSequence(e: KeyboardEvent, key: string): void { + // Non-printable keys (Escape, Tab, Enter, arrows, ...) cancel a pending sequence + if (e.key.length !== 1) { + this.resetSequence(); + return; + } + + const ctx = this.getContext(); + // Add key to sequence this.sequence += key; // Check if sequence matches a command (e.g., "gm", "op") - const sequenceCommand = this.registry.findByKeySequence(this.getContext(), this.sequence); + const sequenceCommand = this.registry.findByKeySequence(ctx, this.sequence); if (sequenceCommand && this.canExecuteCommand(sequenceCommand)) { e.preventDefault(); this.executeCommand(sequenceCommand); @@ -125,9 +166,15 @@ export class ShortcutHandler { return; } + // If the buffer can no longer become a registered sequence, the earlier keys + // were stray - restart from the current key + if (!this.registry.hasKeySequencePrefix(ctx, this.sequence)) { + this.sequence = key; + } + // If sequence is one character, check for single-key shortcut if (this.sequence.length === 1) { - const singleKeyCommand = this.registry.findByShortcut(this.getContext(), key); + const singleKeyCommand = this.registry.findByShortcut(ctx, key); if (singleKeyCommand && this.canExecuteCommand(singleKeyCommand)) { e.preventDefault(); this.executeCommand(singleKeyCommand); diff --git a/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx b/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx index 57ad412ff5a..c8481f6ea25 100644 --- a/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx +++ b/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx @@ -6,16 +6,19 @@ import React from "react"; +const isMacPlatform = (): boolean => + typeof window !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(window.navigator.userAgent); + /** - * Formats a shortcut string for display - * Converts "cmd+shift+," to proper keyboard symbols + * Formats a shortcut string for display, one label per key + * e.g. "cmd+shift+," -> ["⌘", "⇧", ","] on Mac, ["Ctrl", "Shift", ","] elsewhere */ -export const formatShortcutForDisplay = (shortcut: string | undefined): string | null => { - if (!shortcut) return null; +export const formatShortcutForDisplay = (shortcut: string | undefined): string[] => { + if (!shortcut) return []; - const isMac = typeof window !== "undefined" && navigator.platform.toUpperCase().indexOf("MAC") >= 0; + const isMac = isMacPlatform(); - const parts = shortcut.split("+").map((part) => { + return shortcut.split("+").map((part) => { const lower = part.toLowerCase().trim(); // Map to proper symbols @@ -63,51 +66,47 @@ export const formatShortcutForDisplay = (shortcut: string | undefined): string | return part.toUpperCase(); } }); - - return parts.join(""); }; export function ShortcutBadge({ shortcut }: { shortcut: string | undefined }) { - if (!shortcut) return null; + const labels = formatShortcutForDisplay(shortcut); + if (labels.length === 0) return null; - const formatted = formatShortcutForDisplay(shortcut); + // Cumulative prefix is unique per part, unlike the label itself + const parts = labels.map((label, index) => ({ key: labels.slice(0, index + 1).join("+"), label })); return (
- {formatted?.split("").map((char, index) => ( - - - {char.toUpperCase()} - - + {parts.map(({ key, label }) => ( + + {label} + ))}
); } -/** - * Formats key sequence for display (e.g., "gm" -> "G then M") - */ -export const formatKeySequenceForDisplay = (sequence: string | undefined): string => { - if (!sequence) return ""; - - const chars = sequence.split(""); - return chars.map((c) => c.toUpperCase()).join(" then "); -}; - export function KeySequenceBadge({ sequence }: { sequence: string | undefined }) { if (!sequence) return null; - const chars = sequence.split(""); + // Cumulative prefix stays unique for repeated keys such as "gg" + const chars = sequence.split("").map((char, index) => ({ + key: sequence.slice(0, index + 1), + char, + isLast: index === sequence.length - 1, + })); return (
- {chars.map((char, index) => ( - + {chars.map(({ key, char, isLast }) => ( + {char.toUpperCase()} - {index < chars.length - 1 && then} + {!isLast && then} ))}
diff --git a/apps/web/core/components/power-k/ui/modal/wrapper.tsx b/apps/web/core/components/power-k/ui/modal/wrapper.tsx index 25294392c20..a241b403218 100644 --- a/apps/web/core/components/power-k/ui/modal/wrapper.tsx +++ b/apps/web/core/components/power-k/ui/modal/wrapper.tsx @@ -72,6 +72,9 @@ export const ProjectsAppPowerKModalWrapper = observer(function ProjectsAppPowerK // Cmd/Ctrl+K closes palette if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") { e.preventDefault(); + // The Dialog is portaled, so this stops the native event at the portal container + // before the document-level ShortcutHandler can re-open the palette. + e.stopPropagation(); onClose(); return; } From 055198bb6f2adf7e1b52d134092bae710f9f21ce Mon Sep 17 00:00:00 2001 From: vihar Date: Wed, 23 Sep 2026 22:16:33 +0530 Subject: [PATCH 2/5] fix(i18n): translate Power K shortcuts modal strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The shortcuts help modal hard-coded "Keyboard shortcuts", "Search for shortcuts", "No shortcuts found for …" and the "then" separator between key-sequence keycaps. Reuse the existing `keyboard_shortcuts` key and add `power_k.shortcuts_modal.*` to all 21 locales. Also make ShortcutsModal an observer (it reads the observable command registry) and drop the positive tabIndex on its search input. --- .../power-k/ui/modal/command-item-shortcut-badge.tsx | 7 ++++++- .../core/components/power-k/ui/modal/shortcuts-root.tsx | 9 +++++---- .../web/core/components/power-k/ui/renderer/shortcut.tsx | 7 +------ packages/i18n/src/locales/cs/power-k.json | 5 +++++ packages/i18n/src/locales/de/power-k.json | 5 +++++ packages/i18n/src/locales/en/power-k.json | 5 +++++ packages/i18n/src/locales/es/power-k.json | 5 +++++ packages/i18n/src/locales/fr/power-k.json | 5 +++++ packages/i18n/src/locales/id/power-k.json | 5 +++++ packages/i18n/src/locales/it/power-k.json | 5 +++++ packages/i18n/src/locales/ja/power-k.json | 5 +++++ packages/i18n/src/locales/ka-ge/power-k.json | 5 +++++ packages/i18n/src/locales/ko/power-k.json | 5 +++++ packages/i18n/src/locales/nl/power-k.json | 5 +++++ packages/i18n/src/locales/pl/power-k.json | 5 +++++ packages/i18n/src/locales/pt-BR/power-k.json | 5 +++++ packages/i18n/src/locales/ro/power-k.json | 5 +++++ packages/i18n/src/locales/ru/power-k.json | 5 +++++ packages/i18n/src/locales/sk/power-k.json | 5 +++++ packages/i18n/src/locales/tr-TR/power-k.json | 5 +++++ packages/i18n/src/locales/ua/power-k.json | 5 +++++ packages/i18n/src/locales/vi-VN/power-k.json | 5 +++++ packages/i18n/src/locales/zh-CN/power-k.json | 5 +++++ packages/i18n/src/locales/zh-TW/power-k.json | 5 +++++ 24 files changed, 117 insertions(+), 11 deletions(-) diff --git a/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx b/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx index c8481f6ea25..74f5cdf87e2 100644 --- a/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx +++ b/apps/web/core/components/power-k/ui/modal/command-item-shortcut-badge.tsx @@ -5,6 +5,7 @@ */ import React from "react"; +import { useTranslation } from "@plane/i18n"; const isMacPlatform = (): boolean => typeof window !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(window.navigator.userAgent); @@ -90,6 +91,8 @@ export function ShortcutBadge({ shortcut }: { shortcut: string | undefined }) { } export function KeySequenceBadge({ sequence }: { sequence: string | undefined }) { + // translation + const { t } = useTranslation(); if (!sequence) return null; // Cumulative prefix stays unique for repeated keys such as "gg" @@ -106,7 +109,9 @@ export function KeySequenceBadge({ sequence }: { sequence: string | undefined }) {char.toUpperCase()} - {!isLast && then} + {!isLast && ( + {t("power_k.shortcuts_modal.sequence_separator")} + )} ))} diff --git a/apps/web/core/components/power-k/ui/modal/shortcuts-root.tsx b/apps/web/core/components/power-k/ui/modal/shortcuts-root.tsx index 827c79ae130..5b0871b402f 100644 --- a/apps/web/core/components/power-k/ui/modal/shortcuts-root.tsx +++ b/apps/web/core/components/power-k/ui/modal/shortcuts-root.tsx @@ -5,6 +5,7 @@ */ import { useState } from "react"; +import { observer } from "mobx-react"; // plane imports import { Dialog, @@ -32,7 +33,7 @@ type Props = { onClose: () => void; }; -export function ShortcutsModal(props: Props) { +export const ShortcutsModal = observer(function ShortcutsModal(props: Props) { const { isOpen, onClose } = props; // states const [query, setQuery] = useState(""); @@ -86,8 +87,8 @@ export function ShortcutsModal(props: Props) { type="text" value={query} onChange={(e) => setQuery(e.target.value)} - placeholder="Search for shortcuts" - aria-label="Search for shortcuts" + placeholder={t("power_k.shortcuts_modal.search_placeholder")} + aria-label={t("power_k.shortcuts_modal.search_placeholder")} // oxlint-disable-next-line jsx-a11y/no-autofocus -- the shortcut sheet opens on the search field autoFocus /> @@ -100,4 +101,4 @@ export function ShortcutsModal(props: Props) { ); -} +}); diff --git a/apps/web/core/components/power-k/ui/renderer/shortcut.tsx b/apps/web/core/components/power-k/ui/renderer/shortcut.tsx index 9f4d5098430..117bac3fbc8 100644 --- a/apps/web/core/components/power-k/ui/renderer/shortcut.tsx +++ b/apps/web/core/components/power-k/ui/renderer/shortcut.tsx @@ -102,12 +102,7 @@ export function ShortcutRenderer(props: Props) { )) ) : (

- No shortcuts found for{" "} - - {`"`} - {searchQuery} - {`"`} - + {t("power_k.shortcuts_modal.no_results", { query: searchQuery })}

)} diff --git a/packages/i18n/src/locales/cs/power-k.json b/packages/i18n/src/locales/cs/power-k.json index edcdc158c19..e1a7046d53f 100644 --- a/packages/i18n/src/locales/cs/power-k.json +++ b/packages/i18n/src/locales/cs/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Úroveň pracovního prostoru" }, + "shortcuts_modal": { + "search_placeholder": "Hledat klávesové zkratky", + "no_results": "Nenalezeny žádné klávesové zkratky pro „{query}“", + "sequence_separator": "pak" + }, "group_titles": { "actions": "Akce", "contextual": "Kontextové", diff --git a/packages/i18n/src/locales/de/power-k.json b/packages/i18n/src/locales/de/power-k.json index 278be2113aa..2f9226031b3 100644 --- a/packages/i18n/src/locales/de/power-k.json +++ b/packages/i18n/src/locales/de/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Arbeitsbereich-Ebene" }, + "shortcuts_modal": { + "search_placeholder": "Tastaturkürzel suchen", + "no_results": "Keine Tastaturkürzel für „{query}“ gefunden", + "sequence_separator": "dann" + }, "group_titles": { "actions": "Aktionen", "contextual": "Kontextbezogen", diff --git a/packages/i18n/src/locales/en/power-k.json b/packages/i18n/src/locales/en/power-k.json index c00d2e59f6f..a8b5882b9ba 100644 --- a/packages/i18n/src/locales/en/power-k.json +++ b/packages/i18n/src/locales/en/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Workspace level" }, + "shortcuts_modal": { + "search_placeholder": "Search for shortcuts", + "no_results": "No shortcuts found for \"{query}\"", + "sequence_separator": "then" + }, "group_titles": { "actions": "Actions", "contextual": "Contextual", diff --git a/packages/i18n/src/locales/es/power-k.json b/packages/i18n/src/locales/es/power-k.json index 6144f32a8a5..ecf69550c0f 100644 --- a/packages/i18n/src/locales/es/power-k.json +++ b/packages/i18n/src/locales/es/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Nivel de espacio de trabajo" }, + "shortcuts_modal": { + "search_placeholder": "Buscar atajos de teclado", + "no_results": "No se encontraron atajos de teclado para «{query}»", + "sequence_separator": "luego" + }, "group_titles": { "actions": "Acciones", "contextual": "Contextual", diff --git a/packages/i18n/src/locales/fr/power-k.json b/packages/i18n/src/locales/fr/power-k.json index 9461dcdceae..1d74d7f0510 100644 --- a/packages/i18n/src/locales/fr/power-k.json +++ b/packages/i18n/src/locales/fr/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Niveau espace de travail" }, + "shortcuts_modal": { + "search_placeholder": "Rechercher des raccourcis clavier", + "no_results": "Aucun raccourci clavier trouvé pour « {query} »", + "sequence_separator": "puis" + }, "group_titles": { "actions": "Actions", "contextual": "Contextuel", diff --git a/packages/i18n/src/locales/id/power-k.json b/packages/i18n/src/locales/id/power-k.json index accb57b00c7..6c99023a02c 100644 --- a/packages/i18n/src/locales/id/power-k.json +++ b/packages/i18n/src/locales/id/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Tingkat ruang kerja" }, + "shortcuts_modal": { + "search_placeholder": "Cari pintasan keyboard", + "no_results": "Tidak ada pintasan keyboard yang ditemukan untuk \"{query}\"", + "sequence_separator": "lalu" + }, "group_titles": { "actions": "Aksi", "contextual": "Kontekstual", diff --git a/packages/i18n/src/locales/it/power-k.json b/packages/i18n/src/locales/it/power-k.json index 2f7baab3fbf..b0111788a8e 100644 --- a/packages/i18n/src/locales/it/power-k.json +++ b/packages/i18n/src/locales/it/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Livello dello spazio di lavoro" }, + "shortcuts_modal": { + "search_placeholder": "Cerca scorciatoie da tastiera", + "no_results": "Nessuna scorciatoia da tastiera trovata per «{query}»", + "sequence_separator": "poi" + }, "group_titles": { "actions": "Azioni", "contextual": "Contestuale", diff --git a/packages/i18n/src/locales/ja/power-k.json b/packages/i18n/src/locales/ja/power-k.json index b7e66cd18b7..222a2d2cd12 100644 --- a/packages/i18n/src/locales/ja/power-k.json +++ b/packages/i18n/src/locales/ja/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "ワークスペースレベル" }, + "shortcuts_modal": { + "search_placeholder": "キーボードショートカットを検索", + "no_results": "「{query}」のキーボードショートカットが見つかりません", + "sequence_separator": "次に" + }, "group_titles": { "actions": "アクション", "contextual": "コンテキスト", diff --git a/packages/i18n/src/locales/ka-ge/power-k.json b/packages/i18n/src/locales/ka-ge/power-k.json index c00d2e59f6f..a8783db9972 100644 --- a/packages/i18n/src/locales/ka-ge/power-k.json +++ b/packages/i18n/src/locales/ka-ge/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Workspace level" }, + "shortcuts_modal": { + "search_placeholder": "კლავიატურის მალსახმობების ძებნა", + "no_results": "კლავიატურის მალსახმობები \"{query}\"-ისთვის ვერ მოიძებნა", + "sequence_separator": "შემდეგ" + }, "group_titles": { "actions": "Actions", "contextual": "Contextual", diff --git a/packages/i18n/src/locales/ko/power-k.json b/packages/i18n/src/locales/ko/power-k.json index 883f1f5b3a2..57a0f88815b 100644 --- a/packages/i18n/src/locales/ko/power-k.json +++ b/packages/i18n/src/locales/ko/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "작업 공간 수준" }, + "shortcuts_modal": { + "search_placeholder": "키보드 단축키 검색", + "no_results": "\"{query}\"에 대한 키보드 단축키를 찾을 수 없습니다", + "sequence_separator": "다음" + }, "group_titles": { "actions": "액션", "contextual": "컨텍스트", diff --git a/packages/i18n/src/locales/nl/power-k.json b/packages/i18n/src/locales/nl/power-k.json index d93eb2ca06c..af8fa82c05a 100644 --- a/packages/i18n/src/locales/nl/power-k.json +++ b/packages/i18n/src/locales/nl/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Werkruimteniveau" }, + "shortcuts_modal": { + "search_placeholder": "Sneltoetsen zoeken", + "no_results": "Geen sneltoetsen gevonden voor \"{query}\"", + "sequence_separator": "dan" + }, "group_titles": { "actions": "Acties", "contextual": "Contextueel", diff --git a/packages/i18n/src/locales/pl/power-k.json b/packages/i18n/src/locales/pl/power-k.json index 6498a06e513..fcc0305831a 100644 --- a/packages/i18n/src/locales/pl/power-k.json +++ b/packages/i18n/src/locales/pl/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Poziom przestrzeni roboczej" }, + "shortcuts_modal": { + "search_placeholder": "Szukaj skrótów klawiaturowych", + "no_results": "Nie znaleziono skrótów klawiaturowych dla „{query}”", + "sequence_separator": "potem" + }, "group_titles": { "actions": "Akcje", "contextual": "Kontekstowe", diff --git a/packages/i18n/src/locales/pt-BR/power-k.json b/packages/i18n/src/locales/pt-BR/power-k.json index 3b22938cc5f..6aa88128395 100644 --- a/packages/i18n/src/locales/pt-BR/power-k.json +++ b/packages/i18n/src/locales/pt-BR/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Nível do espaço de trabalho" }, + "shortcuts_modal": { + "search_placeholder": "Pesquisar atalhos do teclado", + "no_results": "Nenhum atalho do teclado encontrado para \"{query}\"", + "sequence_separator": "depois" + }, "group_titles": { "actions": "Ações", "contextual": "Contextual", diff --git a/packages/i18n/src/locales/ro/power-k.json b/packages/i18n/src/locales/ro/power-k.json index eca4f240b3d..bea7a3a89d1 100644 --- a/packages/i18n/src/locales/ro/power-k.json +++ b/packages/i18n/src/locales/ro/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "La nivel de spațiu de lucru" }, + "shortcuts_modal": { + "search_placeholder": "Căutați scurtături de tastatură", + "no_results": "Nicio scurtătură de tastatură găsită pentru „{query}”", + "sequence_separator": "apoi" + }, "group_titles": { "actions": "Acțiuni", "contextual": "Contextual", diff --git a/packages/i18n/src/locales/ru/power-k.json b/packages/i18n/src/locales/ru/power-k.json index 6d63a6c5675..5828245212a 100644 --- a/packages/i18n/src/locales/ru/power-k.json +++ b/packages/i18n/src/locales/ru/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Уровень рабочего пространства" }, + "shortcuts_modal": { + "search_placeholder": "Найти горячие клавиши", + "no_results": "Не найдено горячих клавиш для «{query}»", + "sequence_separator": "затем" + }, "group_titles": { "actions": "Действия", "contextual": "Контекстные", diff --git a/packages/i18n/src/locales/sk/power-k.json b/packages/i18n/src/locales/sk/power-k.json index 5117a6826c3..18f08bdb69d 100644 --- a/packages/i18n/src/locales/sk/power-k.json +++ b/packages/i18n/src/locales/sk/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Úroveň pracovného priestoru" }, + "shortcuts_modal": { + "search_placeholder": "Hľadať klávesové skratky", + "no_results": "Nenašli sa žiadne klávesové skratky pre „{query}“", + "sequence_separator": "potom" + }, "group_titles": { "actions": "Akcie", "contextual": "Kontextové", diff --git a/packages/i18n/src/locales/tr-TR/power-k.json b/packages/i18n/src/locales/tr-TR/power-k.json index d5afdec6a08..1228de0e5b2 100644 --- a/packages/i18n/src/locales/tr-TR/power-k.json +++ b/packages/i18n/src/locales/tr-TR/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Çalışma alanı seviyesi" }, + "shortcuts_modal": { + "search_placeholder": "Klavye kısayollarını ara", + "no_results": "\"{query}\" için klavye kısayolu bulunamadı", + "sequence_separator": "sonra" + }, "group_titles": { "actions": "Eylemler", "contextual": "Bağlamsal", diff --git a/packages/i18n/src/locales/ua/power-k.json b/packages/i18n/src/locales/ua/power-k.json index 5e4630fc664..abbfaa4fc37 100644 --- a/packages/i18n/src/locales/ua/power-k.json +++ b/packages/i18n/src/locales/ua/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Рівень робочого простору" }, + "shortcuts_modal": { + "search_placeholder": "Знайти гарячі клавіші", + "no_results": "Не знайдено гарячих клавіш для «{query}»", + "sequence_separator": "потім" + }, "group_titles": { "actions": "Дії", "contextual": "Контекстні", diff --git a/packages/i18n/src/locales/vi-VN/power-k.json b/packages/i18n/src/locales/vi-VN/power-k.json index ef55655e2d6..ecbfb7000fe 100644 --- a/packages/i18n/src/locales/vi-VN/power-k.json +++ b/packages/i18n/src/locales/vi-VN/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "Cấp không gian làm việc" }, + "shortcuts_modal": { + "search_placeholder": "Tìm phím tắt", + "no_results": "Không tìm thấy phím tắt cho \"{query}\"", + "sequence_separator": "rồi" + }, "group_titles": { "actions": "Hành động", "contextual": "Theo ngữ cảnh", diff --git a/packages/i18n/src/locales/zh-CN/power-k.json b/packages/i18n/src/locales/zh-CN/power-k.json index 88e06085141..5ae4bc84c60 100644 --- a/packages/i18n/src/locales/zh-CN/power-k.json +++ b/packages/i18n/src/locales/zh-CN/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "工作区级别" }, + "shortcuts_modal": { + "search_placeholder": "搜索键盘快捷键", + "no_results": "未找到“{query}”的键盘快捷键", + "sequence_separator": "然后" + }, "group_titles": { "actions": "操作", "contextual": "上下文", diff --git a/packages/i18n/src/locales/zh-TW/power-k.json b/packages/i18n/src/locales/zh-TW/power-k.json index 794259af97a..eef86d3ff3a 100644 --- a/packages/i18n/src/locales/zh-TW/power-k.json +++ b/packages/i18n/src/locales/zh-TW/power-k.json @@ -176,6 +176,11 @@ "footer": { "workspace_level": "工作區層級" }, + "shortcuts_modal": { + "search_placeholder": "搜尋鍵盤快速鍵", + "no_results": "找不到「{query}」的鍵盤快速鍵", + "sequence_separator": "然後" + }, "group_titles": { "actions": "操作", "contextual": "情境", From 04e4ed7a3ccc72f60434a5107d9292707894d61d Mon Sep 17 00:00:00 2001 From: vihar Date: Wed, 23 Sep 2026 22:19:56 +0530 Subject: [PATCH 3/5] chore(power-k): remove dead code left from the v2 rewrite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `ui/pages/work-item-selection-page.tsx`: never imported; its body was commented out and referenced a `command-palette` directory and `command_k` i18n namespace that no longer exist - `actions/helper.ts` (`openProjectAndScrollToSidebar`) and its only, commented-out call site in `search-results.tsx` - `ModalData` interface, declared identically in both stores and imported nowhere - `topNavSearchInputRef` / `setTopNavSearchInputRef`: the setter had no callers, so the ⌘F branch that read it was unreachable --- .../core/components/power-k/actions/helper.ts | 31 ---- .../power-k/config/miscellaneous-commands.ts | 12 +- .../power-k/ui/modal/search-results.tsx | 6 - .../ui/pages/work-item-selection-page.tsx | 168 ------------------ .../core/store/base-command-palette.store.ts | 5 - apps/web/core/store/base-power-k.store.ts | 20 --- 6 files changed, 4 insertions(+), 238 deletions(-) delete mode 100644 apps/web/core/components/power-k/actions/helper.ts delete mode 100644 apps/web/core/components/power-k/ui/pages/work-item-selection-page.tsx diff --git a/apps/web/core/components/power-k/actions/helper.ts b/apps/web/core/components/power-k/actions/helper.ts deleted file mode 100644 index a72f9d44134..00000000000 --- a/apps/web/core/components/power-k/actions/helper.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2023-present Plane Software, Inc. and contributors - * SPDX-License-Identifier: AGPL-3.0-only - * See the LICENSE file for details. - */ - -import { store } from "@/lib/store-context"; - -export const openProjectAndScrollToSidebar = (itemProjectId: string | undefined) => { - if (!itemProjectId) { - console.warn("No project id provided. Cannot open project and scroll to sidebar."); - return; - } - // open the project list - store.commandPalette.toggleProjectListOpen(itemProjectId, true); - // scroll to the element - const scrollElementId = `sidebar-${itemProjectId}-JOINED`; - const scrollElement = document.getElementById(scrollElementId); - // if the element exists, scroll to it - if (scrollElement) { - setTimeout(() => { - scrollElement.scrollIntoView({ behavior: "smooth", block: "start" }); - // Restart the highlight animation every time - scrollElement.style.animation = "none"; - // Trigger a reflow to ensure the animation is restarted - void scrollElement.offsetWidth; - // Restart the highlight animation - scrollElement.style.animation = "highlight 2s ease-in-out"; - }); - } -}; diff --git a/apps/web/core/components/power-k/config/miscellaneous-commands.ts b/apps/web/core/components/power-k/config/miscellaneous-commands.ts index 48c9c9da5a0..438c752fe88 100644 --- a/apps/web/core/components/power-k/config/miscellaneous-commands.ts +++ b/apps/web/core/components/power-k/config/miscellaneous-commands.ts @@ -19,13 +19,14 @@ import { usePowerK } from "@/hooks/store/use-power-k"; export const usePowerKMiscellaneousCommands = (): TPowerKCommandConfig[] => { // store hooks const { toggleSidebar } = useAppTheme(); - const { topNavInputRef, topNavSearchInputRef } = usePowerK(); + const { topNavInputRef } = usePowerK(); // translation const { t } = useTranslation(); const copyCurrentPageUrlToClipboard = useCallback(() => { const url = new URL(window.location.href); copyTextToClipboard(url.href) + // oxlint-disable-next-line promise/always-return .then(() => { setToast({ type: "success", @@ -42,13 +43,8 @@ export const usePowerKMiscellaneousCommands = (): TPowerKCommandConfig[] => { }, []); const focusTopNavSearch = useCallback(() => { - // Focus PowerK input if available, otherwise focus regular search input - if (topNavSearchInputRef?.current) { - topNavSearchInputRef.current.focus(); - } else if (topNavInputRef?.current) { - topNavInputRef.current.focus(); - } - }, [topNavInputRef, topNavSearchInputRef]); + topNavInputRef?.current?.focus(); + }, [topNavInputRef]); return [ { diff --git a/apps/web/core/components/power-k/ui/modal/search-results.tsx b/apps/web/core/components/power-k/ui/modal/search-results.tsx index eaa5eb9b876..1cc401c3ced 100644 --- a/apps/web/core/components/power-k/ui/modal/search-results.tsx +++ b/apps/web/core/components/power-k/ui/modal/search-results.tsx @@ -58,12 +58,6 @@ export const PowerKModalSearchResults = observer(function PowerKModalSearchResul onSelect={() => { closePalette(); router.push(currentSection.path(item, projectId)); - // const itemProjectId = - // item?.project_id || - // (Array.isArray(item?.project_ids) && item?.project_ids?.length > 0 - // ? item?.project_ids[0] - // : undefined); - // if (itemProjectId) openProjectAndScrollToSidebar(itemProjectId); }} value={value} /> diff --git a/apps/web/core/components/power-k/ui/pages/work-item-selection-page.tsx b/apps/web/core/components/power-k/ui/pages/work-item-selection-page.tsx deleted file mode 100644 index 4cfe00010b8..00000000000 --- a/apps/web/core/components/power-k/ui/pages/work-item-selection-page.tsx +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Copyright (c) 2023-present Plane Software, Inc. and contributors - * SPDX-License-Identifier: AGPL-3.0-only - * See the LICENSE file for details. - */ - -import { useState, useEffect } from "react"; -// plane imports -// import { useTranslation } from "@plane/i18n"; -import type { TIssueEntityData, TIssueSearchResponse, TActivityEntityData } from "@plane/types"; -// import { generateWorkItemLink } from "@plane/utils"; -// components -// import { CommandPaletteEntityList } from "@/components/command-palette"; -// import { SimpleEmptyState } from "@/components/empty-state/simple-empty-state-root"; -// hooks -// import { useCommandPalette } from "@/hooks/store/use-command-palette"; -// import { usePowerK } from "@/hooks/store/use-power-k"; -// import { useAppRouter } from "@/hooks/use-app-router"; -// plane web imports -// import { IssueIdentifier } from "@/plane-web/components/issues/issue-details/issue-identifier"; -import { WorkspaceService } from "@/services/workspace.service"; - -const workspaceService = new WorkspaceService(); - -type Props = { - workspaceSlug: string | undefined; - projectId: string | undefined; - searchTerm: string; - debouncedSearchTerm: string; - isLoading: boolean; - isSearching: boolean; - resolvedPath: string; - isWorkspaceLevel?: boolean; -}; - -export function WorkItemSelectionPage(props: Props) { - const { workspaceSlug, projectId, debouncedSearchTerm, isWorkspaceLevel = false } = props; - // router - // const router = useAppRouter(); - // plane hooks - // const { t } = useTranslation(); - // store hooks - // const { togglePowerKModal } = usePowerK(); - // states - const [_recentIssues, setRecentIssues] = useState([]); - const [_issueResults, setIssueResults] = useState([]); - - // Load recent issues when component mounts - useEffect(() => { - if (!workspaceSlug) return; - - workspaceService - .fetchWorkspaceRecents(workspaceSlug.toString(), "issue") - .then((res) => - setRecentIssues(res.map((r: TActivityEntityData) => r.entity_data as TIssueEntityData).slice(0, 10)) - ) - .catch(() => setRecentIssues([])); - }, [workspaceSlug]); - - // Search issues based on search term - useEffect(() => { - if (!workspaceSlug || !debouncedSearchTerm) { - setIssueResults([]); - return; - } - - workspaceService - .searchEntity(workspaceSlug.toString(), { - count: 10, - query: debouncedSearchTerm, - query_type: ["issue"], - ...(!isWorkspaceLevel && projectId ? { project_id: projectId.toString() } : {}), - }) - // oxlint-disable-next-line promise/always-return - .then((res) => { - setIssueResults(res.issue || []); - }) - .catch(() => setIssueResults([])); - }, [debouncedSearchTerm, workspaceSlug, projectId, isWorkspaceLevel]); - - if (!workspaceSlug) return null; - - return ( - <> - {/* {searchTerm === "" ? ( - recentIssues.length > 0 ? ( - issue.id} - getLabel={(issue) => `${issue.project_identifier}-${issue.sequence_id} ${issue.name}`} - renderItem={(issue) => ( -
- {issue.project_id && ( - - )} - {issue.name} -
- )} - onSelect={(issue) => { - if (!issue.project_id) return; - togglePowerKModal(false); - router.push( - generateWorkItemLink({ - workspaceSlug: workspaceSlug.toString(), - projectId: issue.project_id, - issueId: issue.id, - projectIdentifier: issue.project_identifier, - sequenceId: issue.sequence_id, - isEpic: issue.is_epic, - }) - ); - }} - emptyText="Search for issue id or issue title" - /> - ) : ( -
Search for issue id or issue title
- ) - ) : issueResults.length > 0 ? ( - issue.id} - getLabel={(issue) => `${issue.project__identifier}-${issue.sequence_id} ${issue.name}`} - renderItem={(issue) => ( -
- {issue.project_id && issue.project__identifier && issue.sequence_id && ( - - )} - {issue.name} -
- )} - onSelect={(issue) => { - if (!issue.project_id) return; - togglePowerKModal(false); - router.push( - generateWorkItemLink({ - workspaceSlug: workspaceSlug.toString(), - projectId: issue.project_id, - issueId: issue.id, - projectIdentifier: issue.project__identifier, - sequenceId: issue.sequence_id, - }) - ); - }} - emptyText={t("command_k.empty_state.search.title") as string} - /> - ) : ( - !isLoading && - !isSearching && ( -
- -
- ) - )} */} - - ); -} diff --git a/apps/web/core/store/base-command-palette.store.ts b/apps/web/core/store/base-command-palette.store.ts index 7b9fb56e869..60bf1493aaa 100644 --- a/apps/web/core/store/base-command-palette.store.ts +++ b/apps/web/core/store/base-command-palette.store.ts @@ -14,11 +14,6 @@ import { EIssuesStoreType } from "@plane/types"; // lib import { store } from "@/lib/store-context"; -export interface ModalData { - store: EIssuesStoreType; - viewId: string; -} - export interface IBaseCommandPaletteStore { // computed isAnyModalOpen: boolean; diff --git a/apps/web/core/store/base-power-k.store.ts b/apps/web/core/store/base-power-k.store.ts index 3d087e41f2f..3ee1c1d3d54 100644 --- a/apps/web/core/store/base-power-k.store.ts +++ b/apps/web/core/store/base-power-k.store.ts @@ -5,18 +5,11 @@ */ import { observable, action, makeObservable } from "mobx"; -// plane imports -import type { EIssuesStoreType } from "@plane/types"; // components import type { IPowerKCommandRegistry } from "@/components/power-k/core/registry"; import { PowerKCommandRegistry } from "@/components/power-k/core/registry"; import type { TPowerKContextType, TPowerKPageType } from "@/components/power-k/core/types"; -export interface ModalData { - store: EIssuesStoreType; - viewId: string; -} - export interface IBasePowerKStore { // observables isPowerKModalOpen: boolean; @@ -25,11 +18,9 @@ export interface IBasePowerKStore { activeContext: TPowerKContextType | null; activePage: TPowerKPageType | null; topNavInputRef: React.RefObject | null; - topNavSearchInputRef: React.RefObject | null; setActiveContext: (entity: TPowerKContextType | null) => void; setActivePage: (page: TPowerKPageType | null) => void; setTopNavInputRef: (ref: React.RefObject | null) => void; - setTopNavSearchInputRef: (ref: React.RefObject | null) => void; // toggle actions togglePowerKModal: (value?: boolean) => void; toggleShortcutsListModal: (value?: boolean) => void; @@ -43,7 +34,6 @@ export class BasePowerKStore implements IBasePowerKStore { activeContext: TPowerKContextType | null = null; activePage: TPowerKPageType | null = null; topNavInputRef: React.RefObject | null = null; - topNavSearchInputRef: React.RefObject | null = null; constructor() { makeObservable(this, { @@ -54,14 +44,12 @@ export class BasePowerKStore implements IBasePowerKStore { activeContext: observable, activePage: observable, topNavInputRef: observable.ref, - topNavSearchInputRef: observable.ref, // toggle actions togglePowerKModal: action, toggleShortcutsListModal: action, setActiveContext: action, setActivePage: action, setTopNavInputRef: action, - setTopNavSearchInputRef: action, }); } @@ -89,14 +77,6 @@ export class BasePowerKStore implements IBasePowerKStore { this.topNavInputRef = ref; }; - /** - * Sets the top nav search input ref for keyboard shortcut access - * @param ref - */ - setTopNavSearchInputRef = (ref: React.RefObject | null) => { - this.topNavSearchInputRef = ref; - }; - /** * Toggles the command palette modal * @param value From 3b4a95e8c22de1e5d62a34b085939619c8cb1a72 Mon Sep 17 00:00:00 2001 From: vihar Date: Thu, 24 Sep 2026 01:52:06 +0530 Subject: [PATCH 4/5] fix(power-k): resolve shortcut keys from the keyboard layout and toggle Cmd+K at the handler Review follow-ups on the shortcut handler: - Match modifier shortcuts against the unshifted character of the physical key, read from `navigator.keyboard.getLayoutMap()` where available. Without it, the US shift map is applied only when `e.code` agrees, so a UK or QWERTZ layout can no longer fire Copy title from Ctrl+Shift+2. Non-Latin layouts resolve letters and digits by physical position, as browser shortcuts do. - Cmd+K now toggles the palette in ShortcutHandler itself; the palette only prevents the default so cmdk's Ctrl+K vim binding does not move the selection. Holding Cmd+K, or pressing it again during the close animation, behaves as a toggle should, and no stopPropagation is involved. - Any key that cannot continue a sequence cancels it: modified keys (Shift+Tab, Cmd+B), keys another component already handled (`defaultPrevented`), and keys typed into inputs. A stray key after a pending prefix is dropped rather than re-read as a single-key shortcut. - Harden the typing guard: