mirror of
https://github.com/wled/WLED.git
synced 2025-07-26 20:26:34 +00:00
move selected to the bottom in search result
This commit is contained in:
parent
8c5e0cd4e9
commit
6fe2024542
@ -2847,11 +2847,16 @@ function search(field, listId = null) {
|
|||||||
// filter list items but leave (Default & Solid) always visible
|
// filter list items but leave (Default & Solid) always visible
|
||||||
const listItems = gId(listId).querySelectorAll('.lstI');
|
const listItems = gId(listId).querySelectorAll('.lstI');
|
||||||
listItems.forEach((listItem, i) => {
|
listItems.forEach((listItem, i) => {
|
||||||
if (listId!=='pcont' && i===0) return;
|
|
||||||
const listItemName = listItem.querySelector('.lstIname').innerText.toUpperCase();
|
const listItemName = listItem.querySelector('.lstIname').innerText.toUpperCase();
|
||||||
const searchIndex = listItemName.indexOf(field.value.toUpperCase());
|
const searchIndex = listItemName.indexOf(field.value.toUpperCase());
|
||||||
listItem.style.display = (searchIndex < 0) && !listItem.classList.contains("selected") ? 'none' : '';
|
if (searchIndex < 0) {
|
||||||
|
listItem.dataset.searchIndex = Number.MAX_SAFE_INTEGER;
|
||||||
|
} else {
|
||||||
listItem.dataset.searchIndex = searchIndex;
|
listItem.dataset.searchIndex = searchIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((listId !== 'pcont' && i === 0) || listItem.classList.contains("selected")) return;
|
||||||
|
listItem.style.display = (searchIndex < 0) ? 'none' : '';
|
||||||
});
|
});
|
||||||
|
|
||||||
// sort list items by search index and name
|
// sort list items by search index and name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user