fomantic / Fomantic-UI

Fomantic-UI is the official community fork of Semantic-UI
https://fomantic-ui.com
MIT License
3.58k stars 333 forks source link

[dropdown] JS error when typing if dropdown open #3027

Open AllanJard opened 8 months ago

AllanJard commented 8 months ago

Bug Report

When a dropdown is open, if you type a letter to match a label in the dropdown, an error occurs:

semantic.min.js?v=2.9.3:11 Uncaught TypeError: Cannot read properties of undefined (reading 'hasClass')
    at Object.selectedLetter (semantic.min.js?v=2.9.3:11:125968)
    at HTMLDivElement.keydown (semantic.min.js?v=2.9.3:11:114089)
    at HTMLDivElement.dispatch (jquery.min.js:2:40035)
    at v.handle (jquery.min.js:2:38006)
selectedLetter @ semantic.min.js?v=2.9.3:11
keydown @ semantic.min.js?v=2.9.3:11
dispatch @ jquery.min.js:2
v.handle @ jquery.min.js:2

Note that you have to type a letter to match a label in the dropdown. If there isn't an entry starting with the letter given, no error will occur.

Steps to reproduce

  1. Go to https://fomantic-ui.com/modules/dropdown.html
  2. Open the "Pet" dropdown (second one on the page - I found it easier to reproduce here than the "File" dropdown - possibly a label / value thing?)
  3. Type "d" on your keyboard
  4. Note the JS error in the browser's console.
  5. Note also that "Dog" is selected
  6. Type "e" - no error
  7. Type "c" (cat) - the error occurs again.

Expected result

No error should be produced. The selected element class is being moved as expected, so I'm not clear if the error is actually stopping any functionality, but the fact that it is happening, means something unexpected is going on.

Actual result

The UI appears to be functional, but the JS error is unexpected.

Testcase

Happens on the Fomantic UI examples: https://fomantic-ui.com/modules/dropdown.html .

Version

2.9.3.

lubber-de commented 8 months ago

Fixed by #3028 Thanks for reporting!

AllanJard commented 8 months ago

Amazingly quick! Putting the rest of us to shame ;-). Thank you for the fix!