Skip to content

Commit e4c2613

Browse files
authored
feat(assets/js): show loading message while waiting for fetched search results (#10948)
Signed-off-by: hainenber <[email protected]>
1 parent eed2acc commit e4c2613

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

assets/js/search.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,18 @@ window.doResultsPageSearch = async (query, type, version) => {
281281
const searchResultsContainer = document.getElementById('searchPageResultsContainer');
282282

283283
try {
284+
// Clear any previous search results
285+
searchResultsContainer.innerHTML = '';
286+
287+
// Display a loading message while fetching results
288+
const loadingElement = document.createElement('div');
289+
loadingElement.textContent = 'Loading...';
290+
searchResultsContainer.appendChild(loadingElement);
291+
284292
const response = await fetch(`https://search-api.opensearch.org/search?q=${query}&v=${version}&t=${type}`);
285293
const data = await response.json();
286-
// Clear any previous search results
294+
295+
// Clear the loading message
287296
searchResultsContainer.innerHTML = '';
288297

289298
if (data.results && data.results.length > 0) {

0 commit comments

Comments
 (0)