Avoid flashing loading state on fast search queries
This commit is contained in:
parent
56b2a004f9
commit
96218f872e
@ -458,9 +458,15 @@
|
||||
clearTimeout(this._suggestTimer);
|
||||
const prefix = ctx.prefix;
|
||||
if (prefix && prefix.length >= 2) {
|
||||
// Show placeholder while loading
|
||||
this._titlesList.innerHTML = '<li class="search-dropdown__item search-dropdown__item--loading">Recherche...</li>';
|
||||
this._tagsList.innerHTML = '<li class="search-dropdown__item search-dropdown__item--loading">Recherche...</li>';
|
||||
// Only show placeholder if lists are empty (avoid flashing on fast typing)
|
||||
const hasTitles = this._titlesList.children.length > 0 && !this._titlesList.querySelector(".search-dropdown__item--loading");
|
||||
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._tagsSection.hidden = false;
|
||||
this.show();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user