Don't hide old item search results if input updates without change

This commit is contained in:
phantamanta44 2021-01-29 15:45:16 -06:00
parent 60451e8f78
commit 4af4c8e1b9

View file

@ -90,10 +90,6 @@ function init() {
// updates the current search state from the search query input boxes // updates the current search state from the search query input boxes
function updateSearch() { function updateSearch() {
// hide old search results
itemListFooter.innerText = '';
for (const itemEntry of itemEntries) itemEntry.style.display = 'none';
// compile query expressions, aborting if nothing has changed or either fails to compile // compile query expressions, aborting if nothing has changed or either fails to compile
const changed = searchFilterField.compile() | searchSortField.compile(); const changed = searchFilterField.compile() | searchSortField.compile();
if (!changed || searchFilterField.output === null || searchSortField.output === null) return; if (!changed || searchFilterField.output === null || searchSortField.output === null) return;
@ -103,6 +99,10 @@ function init() {
+ `?f=${encodeURIComponent(searchFilterField.value)}&s=${encodeURIComponent(searchSortField.value)}`; + `?f=${encodeURIComponent(searchFilterField.value)}&s=${encodeURIComponent(searchSortField.value)}`;
window.history.pushState({ path: newUrl }, '', newUrl); window.history.pushState({ path: newUrl }, '', newUrl);
// hide old search results
itemListFooter.innerText = '';
for (const itemEntry of itemEntries) itemEntry.style.display = 'none';
// index and sort search results // index and sort search results
const searchResults = []; const searchResults = [];
try { try {
@ -172,8 +172,6 @@ function init() {
for (const entryStr of window.location.search.substring(1).split('&')) { for (const entryStr of window.location.search.substring(1).split('&')) {
const ndx = entryStr.indexOf('='); const ndx = entryStr.indexOf('=');
if (ndx !== -1) { if (ndx !== -1) {
console.log(entryStr.substring(0, ndx));
console.log(entryStr.substring(ndx + 1));
switch (entryStr.substring(0, ndx)) { switch (entryStr.substring(0, ndx)) {
case 'f': case 'f':
searchFilterField.field.value = decodeURIComponent(entryStr.substring(ndx + 1)); searchFilterField.field.value = decodeURIComponent(entryStr.substring(ndx + 1));