Skip to content

Conversation

@vihar
Copy link
Contributor

@vihar vihar commented Feb 10, 2025

Description

Improve Power K Menu Navigation and Layout

This PR enhances the Power K menu's usability and visual consistency by:

  1. Relocating the Workspace level selector from top to bottom for better visual hierarchy
  2. Adding keyboard navigation support with Tab key functionality
  3. Fixing inconsistent padding throughout the menu interface

Screenshots and Media

Before:
CleanShot 2025-02-11 at 03 00 50@2x

After:
CleanShot 2025-02-11 at 03 00 42@2x

Type of Change

  • Improvement (change that would cause existing functionality to not work as expected)

Test Scenarios

  • Verify Tab navigation works across all menu sections
  • Ensure Workspace selector remains accessible in its new position
  • Confirm padding is consistent with our design system specifications

Summary by CodeRabbit

  • New Features
    • The command palette now defaults to workspace-level searches.
    • Enhanced keyboard navigation includes Tab cycling and Meta/Ctrl+K shortcuts for quick closure, with refined Escape key behavior.
    • A revamped layout presents command items in a vertical structure.
    • A new bottom overlay displays quick access action shortcuts and a workspace toggle for an improved user interface.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

Walkthrough

The changes update the CommandModal component by altering its default state to favor workspace-level searches. Keyboard interaction logic is enhanced for improved navigation, including Tab key support and a Meta/Ctrl+K shortcut for closing the palette. The Escape key handling now distinguishes between clearing the search term and closing the dialog, and the panel layout has been switched from row to column. Additionally, a bottom overlay has been added to offer quick access to shortcuts and workspace-level toggling.

Changes

File(s) Change Summary
web/core/.../command-palette/command-modal.tsx Modified isWorkspaceLevel default state to true; enhanced onKeyDown handler for Tab navigation and Meta/Ctrl+K to close the palette; refined Escape key logic; updated layout from row to column; added bottom overlay with shortcut labels

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CommandModal
    participant CommandPanel

    User->>CommandModal: Press key (Tab, Meta/Ctrl+K, Escape)
    CommandModal->>CommandModal: Process key event
    alt Tab pressed
        CommandModal->>CommandModal: Move active selection forward
    else Meta/Ctrl+K pressed
        CommandModal->>CommandModal: Trigger palette close
    else Escape pressed
        CommandModal->>CommandModal: Clear search or close palette based on state
    end
    CommandModal->>CommandPanel: Update layout (row → column) and display bottom overlay
    User->>CommandModal: Observe updated interface
Loading

Suggested labels

🌐frontend, 🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

Poem

Hopping through the code, I cheer,
New commands now crystal clear!
With keys that dance and shortcuts bright,
My rabbit heart leaps with delight.
🥕 Happy coding, from day to night!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff3cdad and 04cd8c1.

📒 Files selected for processing (1)
  • web/core/components/command-palette/command-modal.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/command-palette/command-modal.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
web/core/components/command-palette/command-modal.tsx (2)

187-234: Enhance keyboard navigation error handling and accessibility.

The keyboard navigation implementation is good, but could be improved in a few areas:

  1. The Tab key handler should check if the command list exists before accessing it
  2. The focus management could be more robust with ARIA attributes
  3. Error handling for keyboard events could be more comprehensive

Consider this improved implementation:

 onKeyDown={(e: any) => {
   if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
     e.preventDefault();
     e.stopPropagation();
     closePalette();
     return;
   }

   if (e.key === 'Tab') {
     e.preventDefault();
+    try {
       const commandList = document.querySelector('[cmdk-list]');
+      if (!commandList) return;
       const items = commandList?.querySelectorAll('[cmdk-item]') || [];
       const selectedItem = commandList?.querySelector('[aria-selected="true"]');
       
       if (items.length === 0) return;

       const currentIndex = Array.from(items).indexOf(selectedItem as Element);
       let nextIndex;

       if (e.shiftKey) {
         nextIndex = currentIndex > 0 ? currentIndex - 1 : items.length - 1;
       } else {
         nextIndex = currentIndex < items.length - 1 ? currentIndex + 1 : 0;
       }

       const nextItem = items[nextIndex] as HTMLElement;
       
       if (nextItem) {
         nextItem.setAttribute('aria-selected', 'true');
         selectedItem?.setAttribute('aria-selected', 'false');
         nextItem.focus();
+        nextItem.setAttribute('aria-current', 'true');
+        selectedItem?.removeAttribute('aria-current');
         nextItem.scrollIntoView({ 
           behavior: 'smooth', 
           block: 'nearest'
         });
       }
+    } catch (error) {
+      console.error('Error handling Tab navigation:', error);
+    }
   }

440-455: Consider improving keyboard shortcuts accessibility.

The bottom overlay with keyboard shortcuts and workspace toggle is a good addition, but could be more accessible:

  1. Keyboard shortcuts should have proper ARIA labels
  2. The toggle switch should have a more descriptive label

Consider these improvements:

 <div className="w-full flex items-center justify-between px-4 py-2 border-t border-custom-border-200 bg-custom-background-90/80 rounded-b-lg">
   <div className="flex items-center gap-2">
-    <span className="text-xs text-custom-text-300">Actions</span>
+    <span className="text-xs text-custom-text-300" aria-label="Keyboard shortcuts for actions">Actions</span>
     <kbd className="px-2 py-1 text-xs rounded bg-custom-background-80">⌘</kbd>
     <kbd className="px-2 py-1 text-xs rounded bg-custom-background-80">K</kbd>
   </div>
   <div className="flex items-center gap-2">
-    <span className="text-xs text-custom-text-300">Workspace Level</span>
+    <span className="text-xs text-custom-text-300" id="workspace-toggle-label">Search across all projects in workspace</span>
     <ToggleSwitch
       value={isWorkspaceLevel}
       onChange={() => setIsWorkspaceLevel((prevData) => !prevData)}
       size="sm"
+      aria-labelledby="workspace-toggle-label"
     />
   </div>
 </div>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 363507f and ff3cdad.

📒 Files selected for processing (1)
  • web/core/components/command-palette/command-modal.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint-web
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
web/core/components/command-palette/command-modal.tsx (2)

69-69: LGTM! Default workspace level state change aligns with PR objectives.

The change to default isWorkspaceLevel to true improves the initial user experience by providing workspace-wide search by default.


179-179: LGTM! UI layout improvements enhance visual hierarchy.

The changes to flex layout and padding improve the visual organization of the command palette, aligning with the PR's objective to enhance visual consistency.

Also applies to: 243-245

@sriramveeraghanta sriramveeraghanta merged commit 6aa139a into preview Feb 11, 2025
12 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix-power-k-menu branch February 11, 2025 12:10
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
…6580)

* fix: workspace level toggle position, paddings, and tab navigation

* chore: platform-specific command icons

---------

Co-authored-by: Anmol Singh Bhatia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants