Fixed search method
This commit is contained in:
parent
fc67642d10
commit
c25d983a02
@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "parcel ./src/index.html -p 4500 --open ",
|
"start": "parcel src/index.html -p 4500 --open ",
|
||||||
"build": "parcel build ./src/index.html --public-url /cg-select/",
|
"build": "parcel build ./src/index.html --public-url /cg-select/",
|
||||||
"deploy": "gh-pages -d dist",
|
"deploy": "gh-pages -d dist",
|
||||||
"predeploy": "npm run build"
|
"predeploy": "npm run build"
|
||||||
|
@ -758,16 +758,21 @@ export class DropDown {
|
|||||||
|
|
||||||
input.oninput = function () {
|
input.oninput = function () {
|
||||||
let val = this.value.trim();
|
let val = this.value.trim();
|
||||||
|
let anyMatch = false;
|
||||||
|
|
||||||
if (val != '') {
|
if (val != '') {
|
||||||
searchSelect.forEach((elem) => {
|
searchSelect.forEach((elem) => {
|
||||||
|
let isMatching = new RegExp(val, 'gi').test(elem.textContent);
|
||||||
|
anyMatch = anyMatch || isMatching;
|
||||||
|
|
||||||
if (elem.innerText.search(val) == -1) {
|
if (elem.innerText.search(val) == -1) {
|
||||||
elem.classList.add('displayHide');
|
elem.classList.add('displayHide');
|
||||||
result.classList.remove('displayHide');
|
|
||||||
} else {
|
} else {
|
||||||
elem.classList.remove('displayHide');
|
elem.classList.remove('displayHide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
result.classList.toggle('displayHide', anyMatch);
|
||||||
} else {
|
} else {
|
||||||
searchSelect.forEach((elem) => {
|
searchSelect.forEach((elem) => {
|
||||||
elem.classList.remove('displayHide');
|
elem.classList.remove('displayHide');
|
||||||
|
Loading…
Reference in New Issue
Block a user