-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command menu refactoring #9257
Merged
bosiraphael
merged 12 commits into
main
from
9251-the-first-item-of-the-command-menu-should-be-focused-on-open
Dec 30, 2024
Merged
Command menu refactoring #9257
bosiraphael
merged 12 commits into
main
from
9251-the-first-item-of-the-command-menu-should-be-focused-on-open
Dec 30, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR implements automatic first item selection in the command menu to improve keyboard navigation efficiency.
- Added
setSelectedItemId
function inuseSelectableList.ts
to manage item selection state - Introduced
selectFirstItem
boolean prop inSelectableList.tsx
with default false value - Modified
CommandMenu.tsx
to enable first item selection viaselectFirstItem={true}
- Implemented selection reset logic before setting new selections to prevent state conflicts
- Added proper state management for selected items using Recoil selectors and atoms
3 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableList.tsx
Outdated
Show resolved
Hide resolved
thomtrp
reviewed
Dec 27, 2024
packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
Outdated
Show resolved
Hide resolved
bosiraphael
changed the title
Automatically select the first item when opening the command menu
Command menu refactoring
Dec 30, 2024
thomtrp
approved these changes
Dec 30, 2024
bosiraphael
deleted the
9251-the-first-item-of-the-command-menu-should-be-focused-on-open
branch
December 30, 2024 14:22
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactored the
CommandMenu
component to make it more readable and easier to refactor.The file was way too big so I introduced a few hooks and eliminated code duplication.
Introduced:
useMatchCommands
hook to match commands with the searchuseCommandMenuCommands
which returns all command menu commandsuseMatchingCommandMenuCommands
to return the commands matched with the searchCommandMenuContainer
to simplify theDefaultLayout
Unmounted the
CommandMenu
when it wasn't opened to improve performancesI also introduced a new behavior: Automatically select the first item when opening the command menu:
https://github.com/user-attachments/assets/4b683d49-570e-47c9-8939-99f42ed8691c