sort only after filtering is complete
This commit is contained in:
parent
ceb11ae52a
commit
e4150aa8b0
|
@ -156,12 +156,14 @@ function filterOnChange({target: el, forceRefilter}) {
|
||||||
unhide: buildFilter(false),
|
unhide: buildFilter(false),
|
||||||
});
|
});
|
||||||
if (installed) {
|
if (installed) {
|
||||||
reapplyFilter();
|
reapplyFilter().then(() =>
|
||||||
sorter.update();
|
sorter.update());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Promise} resolves on async search
|
||||||
|
*/
|
||||||
function filterAndAppend({entry, container}) {
|
function filterAndAppend({entry, container}) {
|
||||||
if (!container) {
|
if (!container) {
|
||||||
container = [entry];
|
container = [entry];
|
||||||
|
@ -170,15 +172,16 @@ function filterAndAppend({entry, container}) {
|
||||||
entry.classList.add('hidden');
|
entry.classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reapplyFilter(container);
|
return reapplyFilter(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Promise} resolves on async search
|
||||||
|
*/
|
||||||
function reapplyFilter(container = installed, alreadySearched) {
|
function reapplyFilter(container = installed, alreadySearched) {
|
||||||
if (!alreadySearched && $('#search').value.trim()) {
|
if (!alreadySearched && $('#search').value.trim()) {
|
||||||
searchStyles({immediately: true, container})
|
return searchStyles({immediately: true, container})
|
||||||
.then(() => reapplyFilter(container, true));
|
.then(() => reapplyFilter(container, true));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// A: show
|
// A: show
|
||||||
let toHide = [];
|
let toHide = [];
|
||||||
|
@ -191,7 +194,7 @@ function reapplyFilter(container = installed, alreadySearched) {
|
||||||
// showStyles() is building the page and no filters are active
|
// showStyles() is building the page and no filters are active
|
||||||
if (toUnhide instanceof DocumentFragment) {
|
if (toUnhide instanceof DocumentFragment) {
|
||||||
installed.appendChild(toUnhide);
|
installed.appendChild(toUnhide);
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// filtering needed or a single-element job from handleUpdate()
|
// filtering needed or a single-element job from handleUpdate()
|
||||||
for (const entry of toUnhide.children || toUnhide) {
|
for (const entry of toUnhide.children || toUnhide) {
|
||||||
|
@ -208,7 +211,7 @@ function reapplyFilter(container = installed, alreadySearched) {
|
||||||
}
|
}
|
||||||
if (!toHide.length) {
|
if (!toHide.length) {
|
||||||
showFiltersStats();
|
showFiltersStats();
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
for (const entry of toHide) {
|
for (const entry of toHide) {
|
||||||
entry.classList.add('hidden');
|
entry.classList.add('hidden');
|
||||||
|
@ -219,14 +222,14 @@ function reapplyFilter(container = installed, alreadySearched) {
|
||||||
if (container instanceof DocumentFragment) {
|
if (container instanceof DocumentFragment) {
|
||||||
installed.appendChild(container);
|
installed.appendChild(container);
|
||||||
showFiltersStats();
|
showFiltersStats();
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
// single-element job from handleEvent(): add the last wraith
|
// single-element job from handleEvent(): add the last wraith
|
||||||
if (toHide.length === 1 && toHide[0].parentElement !== installed) {
|
if (toHide.length === 1 && toHide[0].parentElement !== installed) {
|
||||||
installed.appendChild(toHide[0]);
|
installed.appendChild(toHide[0]);
|
||||||
}
|
}
|
||||||
showFiltersStats();
|
showFiltersStats();
|
||||||
return;
|
return Promise.resolve();
|
||||||
|
|
||||||
/***************************************/
|
/***************************************/
|
||||||
|
|
||||||
|
|
|
@ -535,8 +535,8 @@ function handleUpdate(style, {reason, method, codeIsUpdated} = {}) {
|
||||||
if ((reason === 'update' || reason === 'install') && entry.matches('.updatable')) {
|
if ((reason === 'update' || reason === 'install') && entry.matches('.updatable')) {
|
||||||
handleUpdateInstalled(entry, reason);
|
handleUpdateInstalled(entry, reason);
|
||||||
}
|
}
|
||||||
filterAndAppend({entry});
|
filterAndAppend({entry}).then(() =>
|
||||||
sorter.update();
|
sorter.update());
|
||||||
if (!entry.matches('.hidden') && reason !== 'import') {
|
if (!entry.matches('.hidden') && reason !== 'import') {
|
||||||
animateElement(entry);
|
animateElement(entry);
|
||||||
requestAnimationFrame(() => scrollElementIntoView(entry));
|
requestAnimationFrame(() => scrollElementIntoView(entry));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user