Update cg-dropdown.js
This commit is contained in:
parent
6cb388d959
commit
0fff32cbed
@ -389,6 +389,8 @@ export class DropDown {
|
|||||||
*/
|
*/
|
||||||
#render(select) {
|
#render(select) {
|
||||||
const { styles, multiselect, searchMode, multiselectTag, darkTheme, lenguage } = this.#options;
|
const { styles, multiselect, searchMode, multiselectTag, darkTheme, lenguage } = this.#options;
|
||||||
|
const { list, search } = styles;
|
||||||
|
|
||||||
const random = Math.random().toString(36).substring(2, 10);
|
const random = Math.random().toString(36).substring(2, 10);
|
||||||
|
|
||||||
if (select || (select && styles)) {
|
if (select || (select && styles)) {
|
||||||
@ -410,14 +412,13 @@ export class DropDown {
|
|||||||
} else {
|
} else {
|
||||||
intputSearch = createInputSearch(random, en.placeholder);
|
intputSearch = createInputSearch(random, en.placeholder);
|
||||||
}
|
}
|
||||||
|
customStylesFormat(search, intputSearch);
|
||||||
ulList.appendChild(intputSearch);
|
ulList.appendChild(intputSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
ulList.classList.add('list');
|
ulList.classList.add('list');
|
||||||
|
|
||||||
if (styles) {
|
if (styles) {
|
||||||
const { list } = styles;
|
|
||||||
customStylesFormat(list, ulList);
|
customStylesFormat(list, ulList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,15 +758,15 @@ export class DropDown {
|
|||||||
});
|
});
|
||||||
|
|
||||||
input.oninput = function () {
|
input.oninput = function () {
|
||||||
let val = this.value.trim();
|
let valueSearch = this.value.trim().toLowerCase();
|
||||||
let anyMatch = false;
|
let anyMatch = false;
|
||||||
|
|
||||||
if (val != '') {
|
if (valueSearch != '') {
|
||||||
searchSelect.forEach((elem) => {
|
searchSelect.forEach((elem) => {
|
||||||
let isMatching = new RegExp(val, 'gi').test(elem.textContent);
|
let isMatching = new RegExp(valueSearch, 'gi').test(elem.textContent);
|
||||||
anyMatch = anyMatch || isMatching;
|
anyMatch = anyMatch || isMatching;
|
||||||
|
|
||||||
if (elem.innerText.search(val) == -1) {
|
if (elem.textContent.toLowerCase().search(valueSearch) == -1) {
|
||||||
elem.classList.add('displayHide');
|
elem.classList.add('displayHide');
|
||||||
} else {
|
} else {
|
||||||
elem.classList.remove('displayHide');
|
elem.classList.remove('displayHide');
|
||||||
|
Loading…
Reference in New Issue
Block a user