-
-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Currently, the ArrowUp and ArrowDown keybind functionality on the Search Dialog Results limits the cursor movement to a maximum of 9 items in the search result. This limitation can be restrictive when there are more than 9 items in the search result. To improve user experience and allow for flexible cursor movement, we should dynamically set the maximum cursor pointable item based on the length of the search result.
screencast-localhost_4321-2024.06.07-22_53_07.webm
Task
-
Replace Fixed Limit: Replace the fixed limit of
9with the length of the search result array.if (resultsCount && e.key === "ArrowUp") { e.preventDefault(); setCursor(cursor === 0 ? Math.min(resultsCount - 1, 9) : cursor - 1); } if (resultsCount && e.key === "ArrowDown") { e.preventDefault(); setCursor(cursor === Math.min(resultsCount - 1, 9) ? 0 : cursor + 1); }
Implementation Steps
- Set Maximum Cursor Pointable Item:
-
Use the length of the search result array to dynamically set the maximum pointable item by replacing the hardcoded
9in thehandleKeyboardCtrlhandler in the file below withsearchResult.lengthi.e.resultsCounts -
File: https://github.com/devjargons/jargons.dev/blob/main/src/components/islands/search.jsx
-
Acceptance Criteria
- The ArrowUp and ArrowDown keybind functionality should dynamically set the maximum cursor pointable item based on the length of the search result array.
- The cursor position should be updated accordingly to prevent it from exceeding the maximum pointable item.
Additional Information
This enhancement will allow users to navigate through the search results more effectively, especially when there are more than 9 items in the search result.