mirror of
https://github.com/wled/WLED.git
synced 2025-07-10 12:26:31 +00:00
Merge pull request #3790 from WoodyLetsCode/fix-preset-sorting
Fix preset sorting
This commit is contained in:
commit
a6d58ee360
@ -2794,7 +2794,12 @@ function search(field, listId = null) {
|
|||||||
if (!listId) return;
|
if (!listId) return;
|
||||||
|
|
||||||
const search = field.value !== '';
|
const search = field.value !== '';
|
||||||
const presets = listId === 'pcont';
|
|
||||||
|
// restore default preset sorting if no search term is entered
|
||||||
|
if (listId === 'pcont' && !search) {
|
||||||
|
populatePresets();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// clear filter if searching in fxlist
|
// clear filter if searching in fxlist
|
||||||
if (listId === 'fxlist' && search) {
|
if (listId === 'fxlist' && search) {
|
||||||
@ -2806,7 +2811,7 @@ function search(field, listId = null) {
|
|||||||
|
|
||||||
const listItems = gId(listId).querySelectorAll('.lstI');
|
const listItems = gId(listId).querySelectorAll('.lstI');
|
||||||
// filter list items but leave (Default & Solid) always visible
|
// filter list items but leave (Default & Solid) always visible
|
||||||
for (i = (presets ? 0 : 1); i < listItems.length; i++) {
|
for (i = (listId === 'pcont' ? 0 : 1); i < listItems.length; i++) {
|
||||||
const listItem = listItems[i];
|
const listItem = listItems[i];
|
||||||
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());
|
||||||
@ -2814,7 +2819,6 @@ function search(field, listId = null) {
|
|||||||
listItem.dataset.searchIndex = searchIndex;
|
listItem.dataset.searchIndex = searchIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!presets) {
|
|
||||||
// sort list items by search index and name
|
// sort list items by search index and name
|
||||||
const sortedListItems = Array.from(listItems).sort((a, b) => {
|
const sortedListItems = Array.from(listItems).sort((a, b) => {
|
||||||
const aSearchIndex = parseInt(a.dataset.searchIndex);
|
const aSearchIndex = parseInt(a.dataset.searchIndex);
|
||||||
@ -2839,7 +2843,6 @@ function search(field, listId = null) {
|
|||||||
firstVisibleItem.scrollIntoView({ behavior: "instant", block: "center" });
|
firstVisibleItem.scrollIntoView({ behavior: "instant", block: "center" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function clean(clearButton) {
|
function clean(clearButton) {
|
||||||
clearButton.style.display = 'none';
|
clearButton.style.display = 'none';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user