bluzky / nice-select2

A lightweight vanilla javascript library that replaces native select elements with customizable dropdowns
https://bluzky.github.io/nice-select2/
MIT License
370 stars 61 forks source link

Cant type space in search bar #14

Closed chromium7 closed 1 year ago

chromium7 commented 3 years ago

When there are options available, space will select the option and scroll the page down. So user cant search with multiple words if there are matches if you type some option in the demo page, it will close the dropdown and scroll down after you type some

akunbeben commented 3 years ago

I think I found why that happened. it's because the focus behavior on the js side. I think it would be better to just have CSS focus, not the actual focus on the element. so users can type more freely.

I can open a PR to give a try 😄

cc @bluzky

image

bluzky commented 3 years ago

thanks @akunbeben could you please create a PR for this.

creativestate commented 3 years ago

If you are using this plugin via the dist folder, an immediate solution is to add the below code snippet on the file dist/nice-select2.js to the a.prototype._onKeyPressed function.

Ideally - beautifying the minified code will make locating this much easier around line 210 after formatting depending on your code formatter.

else if(32 == e.keyCode && open) { return false; }

The above code will allow spaces between words without closing and selecting the first hit from your search.

This dev npm package relies on fsevents API which is macos native - so this limits contributors to macos presently. I am frankly too lazy today to go grab the laptop just to create a build + test / PR request, @bluzky feel free to commit the attached this to the master, I have not tested a build off the attached, so it is best you test this first. Happy for one of the other contributors to test, commit and merge.

nice-select2.zip

Tsjippy commented 2 years ago

can you try I think I fiex the error