Update cg-dropdown.js
This commit is contained in:
parent
734b2b9d56
commit
3160b3d14b
@ -757,16 +757,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