-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: command palette #1611
feat: command palette #1611
Conversation
3ddb8df
to
1b2bac1
Compare
1b2bac1
to
a529dc0
Compare
🚀 Deployed on https://pr-1611--dhis2-ui.netlify.app |
- Launch modal on clicking AllApps icon - Add ordered apps section and action buttons section - Add different views depending on what the user is doing
a529dc0
to
521abe3
Compare
521abe3
to
150e231
Compare
- update data-test ids and classes used to retrieve components - update test titles/scenarios to account for apps, shortcuts and commands
781510b
to
0579262
Compare
setHighlightedIndex(0) | ||
}, [setActiveSection, setCurrentView, setFilter, setHighlightedIndex]) | ||
|
||
const handleListViewNavigation = useCallback( |
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.
It'd be good to have a test for arrow navigation (focusing on edge cases, when list has only one item, when you're at the end of the list etc..)
const lastIndex = itemsArray.length - 1 | ||
switch (event.key) { | ||
case 'ArrowDown': | ||
setHighlightedIndex( |
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.
are we sure we don't need preventDefault for ArrowDown and Up? (maybe ArrowDown scrolls the page?)
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.
lgtm - it'd be good to add tests for navigation with arrow keys (and decide where this will be merged until the backend for shortcuts and commands is implemented)
I noticed that the highlight position is carried over from a unfiltered state to the filtered state.
|
- Retrieve respective actions based on the availability of apps, shortcuts, and commands - Track active index of the highlighted action from the dynamically rendered actions menu - Only show and select grid as active section if apps are available - Highlight first item in the list across all views, i.e. full lists, and search results
- Add tests for the Up and Down arrow key navigation in the list views - Add tests for the Right and Left arrow key navigation in the app grid - Add tests for the search and highlighting functionality in the command palette
🎉 🎉 🎉 |
Merging this to a feature branch 👍 |
Implements 351
Description
The command palette is a one stop search for all apps, commands and shortcuts. (backend implementation pending for the last two). This PR builds the UI (views) to support the execution of this functionality.
Implementation details:
For the implementation, the major building blocks I worked on are:
Views
grid section
of 8 apps, and anactions section
with: a logout link, and conditionally rendered links to the full lists.Sections:
Hooks
filterItemsArray
function to return filtered results of the apps, commands and shortcutsContext
CommandPaletteContext
which contains states of thecurrent view
,filter
,highlighted index
, andactive home view section
, that are consumed and used by the different components within the command palette component to help with navigation, highlighting of items, filtering, and view selection.Others:
filterItemsArray
utils function from this implementation to handle filtering of other items besides the apps.How to test:
http://localhost:5000/
Cmd/Ctrl + /
enter
when they are highlighted,Cmd/Ctrl + /
Esc
Checklist
Screenshots
Home view
Browse apps view
Search Results
Empty Search