Fix: Only preventDefault if there is a highlighted item #1185
4
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I'm relatively new to PR's and am glad to explain or fix anything that would be needed.
In the
listbox
input the key input handler calledpreventDefault
unnecessarily. The comment above on line 364 says that pressing enter with a highlighted item should select it, which should mean that when there is no highlighted item nothing should happen.The current behaviour prevents the input from being used as expected in forms when pressing
Enter
, instead first closing the list and on the second press ofEnter
submitting the form.My current use case is a searchbox with result showing up in the listbox content as you type using bits-ui, which uses this listbox. This is placed in a form that should include the search input as typed when pressing enter, but currently it requires pressing it twice.