fix selecting languages in command menu#862
Conversation
✅ Deploy Preview for livecodes ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughCommand menu behavior updated: UI now triggers native click events for language and processor selections. Core always focuses the command interface on Ctrl+K, opens the command menu after a 500ms delay, and hides the app-help scroller when the menu opens. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Core
participant UI
participant Ninja as NinjaKeys
participant DOM as DOM Elements
rect rgba(240,248,255,0.9)
note over User,Core: Ctrl+K hotkey pressed
User->>Core: Ctrl+K
Core->>Ninja: focus()
alt NinjaKeys not initialized
Core->>Ninja: loadNinjaKeys()
end
Core-->>Core: wait 500ms
Core->>UI: openCommandMenu()
UI->>UI: getAppMenuHelpScroller()?.classList.add("hidden")
end
rect rgba(245,255,240,0.9)
note over User,DOM: Selecting a command item
alt Language selection
UI->>DOM: query [data-editor][data-lang="{lang.name}"]
UI->>DOM: anchor.click()
else Processor selection
UI->>DOM: query input selector
UI->>DOM: dispatchEvent(new Event("click", { bubbles: true }))
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Size Change: -82 B (-0.01%) Total Size: 947 kB ℹ️ View Unchanged
|
Deploying livecodes with
|
| Latest commit: |
58efd27
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f5fca7c2.livecodes.pages.dev |
| Branch Preview URL: | https://fix-command-menu.livecodes.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/livecodes/UI/command-menu-actions.ts (1)
245-250: Fix element typing and prefer native click over synthetic Event.
- The queried element is an input, but the type argument is
HTMLAnchorElement. This is a type mismatch and can hinder type-aware tooling/IDE features.- Use
HTMLElement.click()instead of dispatching a genericEvent('click')to ensure the native click behavior (including togglingcheckedand firing the full event chain) is triggered consistently.Apply this diff:
- document - .querySelector<HTMLAnchorElement>( - '.processor-item input[data-processor="' + processor.name + '"]', - ) - ?.dispatchEvent(new Event('click', { bubbles: true })); + document + .querySelector<HTMLInputElement>( + `.processor-item input[data-processor="${CSS?.escape?.(processor.name) ?? processor.name}"]`, + ) + ?.click();
🧹 Nitpick comments (2)
src/livecodes/UI/command-menu-actions.ts (1)
216-221: Remove debug log; use safe selector construction for data-lang.
console.log(lang.name)is a stray debug log and should be removed to avoid noisy consoles in production.- Build the selector with template literals and CSS.escape to guard against special characters in
lang.name.Apply this diff:
- console.log(lang.name); - document - .querySelector<HTMLAnchorElement>('a[data-editor][data-lang="' + lang.name + '"]') - ?.click(); + const selector = `a[data-editor][data-lang="${CSS?.escape?.(lang.name) ?? lang.name}"]`; + document.querySelector<HTMLAnchorElement>(selector)?.click();src/livecodes/core.ts (1)
2833-2844: Focus timing: focus after opening for more reliable a11y.Focusing the ninja element before it’s opened may be a no-op in some browsers or custom-element implementations. Focusing immediately after the menu opens is more reliable.
Apply this diff:
- ninja.focus(); - requestAnimationFrame(() => openCommandMenu()); + requestAnimationFrame(() => { + openCommandMenu(); + // Focus after open to ensure the element is focusable/visible. + requestAnimationFrame(() => ninja.focus()); + });Please sanity-check the following flows on macOS (Cmd) and Windows/Linux (Ctrl):
- Press-and-release Ctrl/Cmd+K: command menu opens and receives keyboard focus.
- Chorded sequences like Ctrl/Cmd+K, Ctrl/Cmd+0 within 500ms: command menu does NOT open prematurely.
- Help menu visibility: open help, then open command menu (help scroller should hide), then reopen help (it should show again).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/livecodes/UI/command-menu-actions.ts(2 hunks)src/livecodes/core.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Redirect rules - livecodes
- GitHub Check: Header rules - livecodes
- GitHub Check: Pages changed - livecodes
- GitHub Check: build (18.x)
- GitHub Check: tests (18.x, 1)
- GitHub Check: tests (18.x, 4)
- GitHub Check: tests (18.x, 5)
- GitHub Check: type-check (18.x)
- GitHub Check: tests (18.x, 3)
- GitHub Check: tests (18.x, 2)
- GitHub Check: build
- GitHub Check: build (18.x)
- GitHub Check: type-check (18.x)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
src/livecodes/core.ts (1)
2801-2804: Good UX: hide help scroller when opening the command menu.Hiding the app-help scroller avoids visual conflicts when the command menu opens. Change looks correct and low risk.
|



Summary by CodeRabbit
Bug Fixes
Refactor