-
Notifications
You must be signed in to change notification settings - Fork 4
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
Introduction of the Search Feature in the Frontend #161
Conversation
This commit introduces a search bar component to the navigation pane. A corresponding API function to fetch search results has also been added. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Replaced the manual dropdown search implementation with Material UI's Autocomplete component. This simplifies the Search component by removing unnecessary state and event handlers. The Autocomplete component also provides a better user experience by automatically filtering and displaying search results. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
The search component functionality was improved by making it more interactive and user-friendly. The search results now return the smallest unique path segment in case of duplicate names, enhancing user experience. The dropdown visibility is also managed based on the search results. This ensures that the dropdown only appears when there are actual search results. Additionally, the 'selectedRegion' state is now updated with detailed region information obtained from the API, providing more context to the user. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
The Search component has been updated to check if the selected region is the same as the search term, and if so, the function will return early. This change prevents unnecessary searches when the selected region and search term are identical. Additionally, the commit improves the function that transforms an option into a string representation, making it more robust. If the option is a string, it is returned directly. If it is not an object or does not have a name property, an empty string is returned. Lastly, the unnecessary console log in the onInputChange event handler has been removed. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
WalkthroughThe overall change introduces a search functionality to the frontend, allowing users to search for regions by name or path. It includes a new Changes
Assessment against linked issues
Related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
Apply Sweep Rules to your PR?
Type can be one of the following:
|
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.
Review Status
Actionable comments generated: 4
Configuration used: .coderabbit.yaml
Files selected for processing (5)
- frontend/README.md (2 hunks)
- frontend/src/api/index.js (1 hunks)
- frontend/src/components/ListOfRegions.jsx (2 hunks)
- frontend/src/components/NavigationPane.jsx (2 hunks)
- frontend/src/components/Search.jsx (1 hunks)
Additional comments: 8
frontend/README.md (2)
49-49: The addition of
Search.jsx
to the directory structure is correctly documented.94-116: The Features section provides a clear and comprehensive overview of the new search functionality and its UI/UX considerations.
frontend/src/api/index.js (1)
- 80-91: The implementation of
fetchSearchResults
correctly handles the 204 status code and errors, returning an empty array as expected.frontend/src/components/NavigationPane.jsx (1)
- 16-16: The integration of the
Search
component into theNavigationPane
is correctly implemented and follows React best practices.frontend/src/components/Search.jsx (4)
6-190: The
Search
component is well-implemented, with debouncing and error handling in place. It follows React best practices for state management and effects.14-47: The
formatNames
function correctly handles the formatting of search result names, ensuring unique identification for regions with identical names.49-106: The useEffect hook in the
Search
component is correctly implemented with debouncing and cleanup to prevent memory leaks and unnecessary API calls.117-187: The implementation of the Material-UI Autocomplete component within the
Search
component is correct and follows best practices for responsive and accessible UI.
This commit refactors the ListOfRegions.jsx file to fetch the siblings of a selected region. The changes include: - Importing the `fetchAncestors` function from the API module. - Modifying the `fetchRegions` function to fetch the siblings of a selected region if it does not have any subregions. The process involves fetching the parent of the selected region (which is the second item in the ancestors array) and then fetching its subregions. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
This commit introduces the `useRef` hook inside the `Search` component in the frontend. The `useRef` hook is used to keep track of the `selectedRegion` and to determine whether the `selectedRegion` has changed. This is done to prevent unnecessary API calls when the `selectedRegion` has not actually been modified. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Modified the Search component to allow force searching by pressing the Enter key. This change was implemented by creating a new state variable 'searchTerm' as an object with 'name' and 'force' properties. The 'force' property is set to true when the Enter key is pressed, triggering the fetchResults function to execute immediately rather than waiting for the user to stop typing. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
Updated `README.md` to include the documentation for the new search feature, explaining its UI/UX considerations and its interaction with the backend. Issue: #151 Signed-off-by: Nikolay Martyanov <ohmspectator@gmail.com>
c2c8b43
to
098163c
Compare
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yaml
Files selected for processing (5)
- frontend/README.md (2 hunks)
- frontend/src/api/index.js (1 hunks)
- frontend/src/components/ListOfRegions.jsx (2 hunks)
- frontend/src/components/NavigationPane.jsx (2 hunks)
- frontend/src/components/Search.jsx (1 hunks)
Files skipped from review as they are similar to previous changes (5)
- frontend/README.md
- frontend/src/api/index.js
- frontend/src/components/ListOfRegions.jsx
- frontend/src/components/NavigationPane.jsx
- frontend/src/components/Search.jsx
Description
This PR marks the introduction and subsequent enhancements of the search functionality in the application's frontend. It begins with the initial addition of a search bar in the navigation pane, followed by a series of improvements for better user experience and efficiency. These enhancements include the integration of Material UI's Autocomplete component, refined search logic, improved option string handling, and the ability to fetch siblings in the ListOfRegions.jsx. Additionally, comprehensive documentation for the new search feature has been added, covering UI/UX considerations and backend interaction.
Related Issues
Closes: #151
How Was This Tested?
Testing was conducted through hands-on interaction with the search feature. Various regions were searched to evaluate the UI response. This included testing with specific region names and partial path inputs (e.g., "Germany Berlin"), to assess the accuracy and efficiency of the search results. The performance of the Material UI's Autocomplete component, in terms of user experience and functionality, was also a key aspect of the testing.
Checklist
Before submitting your PR, please review the following:
Additional Comments (if any):
This PR is a significant milestone in developing the application's frontend, providing a robust and user-friendly search functionality. Future iterations could focus on further optimizing backend interactions and refining UI/UX based on user feedback.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes