Advanced Command Palette with Hierarchical Navigation
Meesho's internal tools are crucial for managing our vast catalog, seller operations, and customer orders. As we scale, power users need increasingly efficient ways to navigate and execute actions. A unified, intelligent command palette can significantly boost productivity by providing quick access to deep functionalities across different modules, minimizing clicks and context switching.
This problem challenges you to build a sophisticated command palette component for our internal platform. It should not only allow users to search and execute commands but also intelligently handle hierarchical command structures, enabling users to drill down into categories and perform actions within specific contexts.
Your primary task is to implement a reusable CommandPalette React component that offers an intuitive and powerful user experience. Specifically, you must:
Cmd+K or Ctrl+K, and by clicking outside or pressing Esc).ArrowUp and ArrowDown to navigate through the list of filtered commands.Enter to select a command (execute an action command or drill into a category command).Backspace or Delete to navigate up one level in the command hierarchy when inside a category (only if the search input is empty).Escape to close the palette from any state.Enter is pressed, an onExecute callback should be triggered with the command's ID.Catalog > Products).Cmd+K/Ctrl+K) and Esc key.ArrowUp, ArrowDown, Enter, Backspace/Delete, Esc) function correctly for navigation, selection, and closing.onExecute prop with the correct command ID.Constraints
Command objects. You can assume this structure is immutable during the component's lifecycle.Loading editor...