Skip to content

PR2: Added search UI#1716

Merged
Pikalot merged 28 commits intodevTA_shortcut_keyfrom
devTA_search_ui
Jul 3, 2025
Merged

PR2: Added search UI#1716
Pikalot merged 28 commits intodevTA_shortcut_keyfrom
devTA_search_ui

Conversation

@Pikalot
Copy link
Copy Markdown
Collaborator

@Pikalot Pikalot commented Jun 19, 2025

This PR introduces a search feature triggered by a shortcut key.

⚠️ Please merge PR #1715 first.

@Pikalot Pikalot requested review from evanugarte and weslayer June 19, 2025 04:41
@Pikalot Pikalot changed the base branch from dev to devTA_shortcut_key June 26, 2025 05:25
Comment thread src/Components/ShortcutKeyModal/SearchModal.js Outdated
Comment thread src/Components/ShortcutKeyModal/SearchModal.js Outdated
Comment thread src/Components/ShortcutKeyModal/SearchModal.js Outdated
Comment thread src/Components/ShortcutKeyModal/SearchModal.js Outdated
Comment thread src/Pages/Home/Home.js Outdated
Comment thread src/index.js Outdated
Comment thread src/Components/ShortcutKeyModal/SearchModal.module.css Outdated
Comment on lines +108 to +126
{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)}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

im not sure if this comment was addressed, maybe some commits need to be pushed to github?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

sorry, I was delaying it because I wanted to push it together with the scoped CSS. It should be live now.

Comment thread src/Components/ShortcutKeyModal/SearchModal.js Outdated
@@ -0,0 +1,65 @@
.modal {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

https://github.com/SCE-Development/Clark/pull/1256/files

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done, please review

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can the class name be shortcut-search-modal,

modal is kind of generic, we might use this class name somewhere else on accident

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Pikalot and others added 2 commits July 3, 2025 11:11
Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com>
Co-authored-by: Evan Ugarte <36345325+evanugarte@users.noreply.github.com>
Comment thread src/Components/ShortcutKeyModal/SearchModal.js Outdated
Comment on lines +108 to +126
{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)}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

im not sure if this comment was addressed, maybe some commits need to be pushed to github?

@@ -0,0 +1,65 @@
.modal {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can the class name be shortcut-search-modal,

modal is kind of generic, we might use this class name somewhere else on accident

Pikalot added 2 commits July 3, 2025 12:52
…d CSS and renamed the class from modal to search-modal. Added a check for an empty suggestions list before handling search.
@Pikalot Pikalot merged commit ed3f51b into devTA_shortcut_key Jul 3, 2025
@Pikalot Pikalot deleted the devTA_search_ui branch July 3, 2025 20:54
@Pikalot Pikalot restored the devTA_search_ui branch July 3, 2025 21:03
evanugarte added a commit that referenced this pull request Jul 7, 2025
* 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>
aeiouny pushed a commit to aeiouny/Clark that referenced this pull request Jul 7, 2025
…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>
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.

2 participants