valor-software / ng2-select

Angular based replacement for select boxes
http://valor-software.github.io/ng2-select/
MIT License
676 stars 588 forks source link

Fix search #916

Open pista opened 6 years ago

pista commented 6 years ago

Fixes this issue: https://github.com/valor-software/ng2-select/issues/915

The original query.test() keeps a global variable that interferes with evaluation of consequitive strings. Refere to example here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test

Basically, if the si.children array contains [ "hello", "llo" ], and we search for "llo", it will not find the second item, as regex.lastIndex is set to 2.

This will make the code consistent with GenericBehavior.filter().

codecov[bot] commented 6 years ago

Codecov Report

Merging #916 into development will not change coverage. The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff              @@
##           development     #916   +/-   ##
============================================
  Coverage        28.41%   28.41%           
============================================
  Files               11       11           
  Lines              447      447           
  Branches            81       81           
============================================
  Hits               127      127           
  Misses             314      314           
  Partials             6        6
Impacted Files Coverage Δ
src/select/select.ts 16.81% <0%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 855ac2f...8ce81fb. Read the comment docs.

optimistex commented 6 years ago

I had included your commit in the greater update: #921