select: Error in case of empty items array
- Dominant language
- JavaScript
- Stars
- 330
- Forks
- 88
- PR merge metrics
- No merged PRs in 30d
Description
Hello all. I found some strange code in select block which gives me error in case of empty select item array on select click.
``` js
_hoverCheckedOrFirstItem : function() { // NOTE: may be it should be moved to menu
(this._getCheckedItems()[0] || this._menu.getItems()[0])
.setMod('hovered');
},
```
It is simple to understand that in case of empty array this._menu.getItems()[0] will gives error with message: 'Uncaught TypeError: Cannot read property 'setMod' of undefined'
Contributor guide
Research direction
Start in the select block at _hoverCheckedOrFirstItem and reproduce the error by clicking a select with an empty item array. Trace the item lookup and existing select behavior to determine the intended empty-state handling. Done means the click no longer throws the reported TypeError; the payload names no file or test to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100