Avoid flashing loading state on fast search queries

This commit is contained in:
2026-05-27 11:39:37 -04:00
parent 56b2a004f9
commit 96218f872e
+9 -3
View File
@@ -458,9 +458,15 @@
clearTimeout(this._suggestTimer); clearTimeout(this._suggestTimer);
const prefix = ctx.prefix; const prefix = ctx.prefix;
if (prefix && prefix.length >= 2) { if (prefix && prefix.length >= 2) {
// Show placeholder while loading // Only show placeholder if lists are empty (avoid flashing on fast typing)
this._titlesList.innerHTML = '<li class="search-dropdown__item search-dropdown__item--loading">Recherche...</li>'; const hasTitles = this._titlesList.children.length > 0 && !this._titlesList.querySelector(".search-dropdown__item--loading");
this._tagsList.innerHTML = '<li class="search-dropdown__item search-dropdown__item--loading">Recherche...</li>'; const hasTags = this._tagsList.children.length > 0 && !this._tagsList.querySelector(".search-dropdown__item--loading");
if (!hasTitles) {
this._titlesList.innerHTML = '<li class="search-dropdown__item search-dropdown__item--loading">Recherche...</li>';
}
if (!hasTags) {
this._tagsList.innerHTML = '<li class="search-dropdown__item search-dropdown__item--loading">Recherche...</li>';
}
this._titlesSection.hidden = false; this._titlesSection.hidden = false;
this._tagsSection.hidden = false; this._tagsSection.hidden = false;
this.show(); this.show();