openedx / openedx/paragon

[paragon-openedx.netlify.app] Feedback (on /components/menu/select-menu/)

Open
#2,996 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
JavaScript
Stars
140
Forks
100
Avg merge
1h 3m
Merged PRs (30d)
30

Description

Feedback summary

I wanted to flag some potentially less than ideal behavior related to the SelectMenu component that I noticed while working with this and the SearchField component. Below is more detailed context:

I was attempting to create a SelectMenu that has a SearchField as its first MenuItem. When an MenuItem is selected, selected is set based on the index in SelectMenu.jsx here. This const is then used to set the offset to scroll to the center of the menu here.

image

The problem is, that when a user selects an item in the menu, THEN searches using the search field, they get this error: TypeError Cannot read properties of undefined (reading 'current'). This only happens when the selected item has an index that is beyond the range of the filtered MenuItems array.

Screenshot 2024-01-25 at 2 31 20 PM

Improvements

If the number of MenuItems changes in a SelectMenu (like in the example above when the items are filtered using a SearchField), then the selected const should be updated to reflect this change. Otherwise, there will be a TypeError.

Bugs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Menu/SelectMenu.jsx at the selected calculation around line 38 and the scroll offset around line 62, with the SearchField and filtered MenuItem behavior described in the issue. Reproduce selecting an item and then filtering the menu; done means filtering no longer causes the undefined-current TypeError and selected reflects the changed items.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.