bluzky/nice-select2

Cant type space in search bar

chromium7 opened this issue · 4 comments

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

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

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

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

can you try I think I fiex the error