Merge pull request #46 from w00000dy/search-keep-mod

Move selected to the bottom in search result
This commit is contained in:
Blaž Kristan 2024-11-16 22:54:11 +01:00 committed by GitHub
commit 25ab381916
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2850,8 +2850,12 @@ function search(field, listId = null) {
if (listId !== 'pcont' && i === 0) return;
const listItemName = listItem.querySelector('.lstIname').innerText.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.style.display = (searchIndex < 0) && !listItem.classList.contains("selected") ? 'none' : '';
});
// sort list items by search index and name