jargonsdev / jargons.dev

A community-driven dictionary that simplifies software, engineering and tech terms for all levels.
https://jargons.dev
GNU General Public License v2.0
24 stars 8 forks source link

Search Dialog: Dynamically Set Maximum Cursor Pointable Item #78

Closed babblebey closed 2 months ago

babblebey commented 5 months ago

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

  1. Replace Fixed Limit: Replace the fixed limit of 9 with 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

  1. Set Maximum Cursor Pointable Item:

Acceptance Criteria

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.

Bridgetamana commented 2 months ago

please assign this to me

babblebey commented 2 months ago

Hey @Bridgetamana, have at it 😉

Don't hesitate to ask questions if you need any clarity following the steps.