PR2: Added search UI#1716
Conversation
2. Suggestions instantly display hardcoded pages recommendations. 3. Suggestions show user search results after a short delay for authorized users only and if there is any user matched
…fficer is Officer and Manager
Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com>
Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com>
| {suggestions.length > 0 && ( | ||
| <ul className={`${style['suggestion-list']}`}> | ||
| {suggestions.map((r, index) => ( | ||
| <li | ||
| key={index} | ||
| className={`${style['suggestion-item']} ${index === selectItem ? style['active'] : ''}`} | ||
| onMouseEnter={() => setSelectItem(index)} | ||
| onClick={() => { | ||
| window.location.href = r.path; | ||
| setOpen(false); | ||
| }} | ||
| > | ||
| <span style={{ marginRight: '0.5rem' }}> | ||
| {r.type === 'user' ? '👤' : '📄'} | ||
| </span> | ||
| {r.pageName} | ||
| <div className={style['hidden-tab']}>{selectItem === index && `${window.location.origin}${r.path}`}</div> | ||
| </li> | ||
| )).slice(0, 5)} |
There was a problem hiding this comment.
can we move this to a function, like
getSuggestions()
it returns an empty tag if suggestions.length === 0, else it gets the first 5 suggesitons, and returns the <li> elements after using a map function
There was a problem hiding this comment.
im not sure if this comment was addressed, maybe some commits need to be pushed to github?
There was a problem hiding this comment.
sorry, I was delaying it because I wanted to push it together with the scoped CSS. It should be live now.
| @@ -0,0 +1,65 @@ | |||
| .modal { | |||
There was a problem hiding this comment.
we should scope the css, so every element in the search modal should be inside of a div called "search-modal",
that way we dont accidentally apply this css to other components in clark with the same class name
an example of this issue, and resolving this issue with scoping is in the below pr
There was a problem hiding this comment.
Done, please review
There was a problem hiding this comment.
can the class name be shortcut-search-modal,
modal is kind of generic, we might use this class name somewhere else on accident
There was a problem hiding this comment.
I renamed it to search-modal before seeing your suggestion. I can still rename it to shortcut-search-modal if you prefer that name for clarity.
Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com>
Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com>
| {suggestions.length > 0 && ( | ||
| <ul className={`${style['suggestion-list']}`}> | ||
| {suggestions.map((r, index) => ( | ||
| <li | ||
| key={index} | ||
| className={`${style['suggestion-item']} ${index === selectItem ? style['active'] : ''}`} | ||
| onMouseEnter={() => setSelectItem(index)} | ||
| onClick={() => { | ||
| window.location.href = r.path; | ||
| setOpen(false); | ||
| }} | ||
| > | ||
| <span style={{ marginRight: '0.5rem' }}> | ||
| {r.type === 'user' ? '👤' : '📄'} | ||
| </span> | ||
| {r.pageName} | ||
| <div className={style['hidden-tab']}>{selectItem === index && `${window.location.origin}${r.path}`}</div> | ||
| </li> | ||
| )).slice(0, 5)} |
There was a problem hiding this comment.
im not sure if this comment was addressed, maybe some commits need to be pushed to github?
| @@ -0,0 +1,65 @@ | |||
| .modal { | |||
There was a problem hiding this comment.
can the class name be shortcut-search-modal,
modal is kind of generic, we might use this class name somewhere else on accident
…d CSS and renamed the class from modal to search-modal. Added a check for an empty suggestions list before handling search.
* chore: move routes array to its own file * Removed search UI * Re-commit for PR 1 * Added search UI * update: Only 5 search suggestions are shown at once. Scroll to see more. * Debug: remove dessert pages * Fixed bug: user should land homepage after loggin in * Update: Prevent unnecessary API calls — user data is now fetched only when the search input actually changes. * Resolved conflict when merging with latest dev * Resolved incoming conflict when merging with dev * Removed search UI codes and improved permission check logic by implementing Lookup table * Fixed irrelevant permission check * Fixed lookup table to prevent excessive fetching * Improved routes caching in SearchModal using useMemo * 1. Removed scrollable dropdown codes. Just shows top 5 results. 2. Suggestions instantly display hardcoded pages recommendations. 3. Suggestions show user search results after a short delay for authorized users only and if there is any user matched * removed e.key === 'K', only implement api fetch for users list when officer is Officer and Manager * Fix: hide search suggestions when input is empty * Refactor: removed duplicate route filtering and improved keyboard selection logic * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Committed changes as suggestions * Undo the changes in Home.js * Removed a space in line 1 of Home.js * Spitted PR and moved searching debounce logic to the new PR * Updated PERMISSION_LOOKUP_TABLE in Private Route -> no more functions mapping, cleaner code * Removed the commented out section - old SpeakerPage component * Removed unnecessary pageName prop * Resolved conflicts due to auto correction * Fixed typo: signedInRoutes * Added more arrays to RouteConfig.js * Changed RouteConfig.js to Routes.js and fixed linting errors * Merged with Aidan's routes.js code * Update src/index.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Used scoped CSS * Moved suggestions rendering to a separate function. Switched to scoped CSS and renamed the class from modal to search-modal. Added a check for an empty suggestions list before handling search. * Rerversed merging with PR2. Waiting for approval * Recreated PR2 * Changed className: search-modal -> shortcut-search-modal * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Changed key to r.path and slice top 5 suggestions before rendering * Changes: close search modal when users click outside of the modal content, clear out search box when modal is closed * Added dark mode, refined UI, and showed default signedOutRoutes suggestions when keyword is empty * Changed background color of suggestion list to be more neutral in Light mode * Rebased with main * Renamed getSuggestions to SuggestionsList and converted all functions to arrow functions * Removed 'Get Started row' and filtered out Edit User Info page * Fix: correct dependencies in useMemo for routes --------- Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> Co-authored-by: Aidan Spies <spiesaidan@gmail.com>
…E-Development#1748) * chore: move routes array to its own file * Removed search UI * Re-commit for PR 1 * Added search UI * update: Only 5 search suggestions are shown at once. Scroll to see more. * Debug: remove dessert pages * Fixed bug: user should land homepage after loggin in * Update: Prevent unnecessary API calls — user data is now fetched only when the search input actually changes. * Resolved conflict when merging with latest dev * Resolved incoming conflict when merging with dev * Removed search UI codes and improved permission check logic by implementing Lookup table * Fixed irrelevant permission check * Fixed lookup table to prevent excessive fetching * Improved routes caching in SearchModal using useMemo * 1. Removed scrollable dropdown codes. Just shows top 5 results. 2. Suggestions instantly display hardcoded pages recommendations. 3. Suggestions show user search results after a short delay for authorized users only and if there is any user matched * removed e.key === 'K', only implement api fetch for users list when officer is Officer and Manager * Fix: hide search suggestions when input is empty * Refactor: removed duplicate route filtering and improved keyboard selection logic * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Committed changes as suggestions * Undo the changes in Home.js * Removed a space in line 1 of Home.js * Spitted PR and moved searching debounce logic to the new PR * Updated PERMISSION_LOOKUP_TABLE in Private Route -> no more functions mapping, cleaner code * Removed the commented out section - old SpeakerPage component * Removed unnecessary pageName prop * Resolved conflicts due to auto correction * Fixed typo: signedInRoutes * Added more arrays to RouteConfig.js * Changed RouteConfig.js to Routes.js and fixed linting errors * Merged with Aidan's routes.js code * Update src/index.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Used scoped CSS * Moved suggestions rendering to a separate function. Switched to scoped CSS and renamed the class from modal to search-modal. Added a check for an empty suggestions list before handling search. * Rerversed merging with PR2. Waiting for approval * Recreated PR2 * Changed className: search-modal -> shortcut-search-modal * Update src/Components/ShortcutKeyModal/SearchModal.js Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> * Changed key to r.path and slice top 5 suggestions before rendering * Changes: close search modal when users click outside of the modal content, clear out search box when modal is closed * Added dark mode, refined UI, and showed default signedOutRoutes suggestions when keyword is empty * Changed background color of suggestion list to be more neutral in Light mode * Rebased with main * Renamed getSuggestions to SuggestionsList and converted all functions to arrow functions * Removed 'Get Started row' and filtered out Edit User Info page * Fix: correct dependencies in useMemo for routes --------- Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com> Co-authored-by: Aidan Spies <spiesaidan@gmail.com>
This PR introduces a search feature triggered by a shortcut key.