Mobius1/Selectr

Search results sensitive to spaces and dashes (hyphens)

Closed this issue · 2 comments

Hey guys,

Is it possible to "ignore" spaces and dashes when entered into search?

For example, in the demo:

https://codepen.io/Mobius1/pen/QgdpLN

If you test the selectr in the top, right corner you can see that the Data includes "access-point".

However, if you search for "access point" you can see that there are no options.

In these cases, would it be possible to simply ignore the "-"?

Thanks!

okay, I think I figured out how

within Selectr.js on line 218, replace:

var matches = compare( option.textContent.trim().toLowerCase(), string );

with

var matches = compare( option.textContent.trim().toLowerCase().replace(/-|\s/g,""), string.replace(/-|\s/g,"") );

Then, minify selectr.js and place in selectr.min.js.

Note pull request:
#141