Skip to content

Commit aaa3f05

Browse files
authored
Ensure loading indicator is visible when needed (#93)
When a user runs an AI explanation, English search, or image analysis, make sure they see the loading dots. If they're out of view it seems like nothing happened. As usual, this is code we should improve on.
1 parent 88579ed commit aaa3f05

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

public/js/modules/explore.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ let setupExamples = function (words, type, skipState, allowExplain, aiData) {
965965
aiResponseContainer.style.display = 'none';
966966
aiResponseContainer.classList.add('ai-explanation-container');
967967
examplesList.appendChild(loadingDots);
968+
document.getElementById('explore-container').scrollTo({ top: 0 });
968969
examplesList.appendChild(aiResponseContainer);
969970
const wordsWithoutIgnored = words.map(x => x.ignore ? x.word : x);
970971
let joinedText = wordsWithoutIgnored.join('');
@@ -1104,6 +1105,9 @@ let initialize = function () {
11041105
// soon be cleared by a rendering of examples (this is a bad assumption)
11051106
// (but at least there's a hide below, surely no client would ever mix that up)
11061107
examplesList.prepend(loadingDots);
1108+
// make sure the loading dots show up instead of leaving the user guessing what happened
1109+
// TODO: get rid of this getElementById here
1110+
document.getElementById('explore-container').scrollTo({ top: 0 });
11071111
});
11081112
document.addEventListener('hide-loading-dots', function () {
11091113
const existingLoadingDots = examplesList.querySelector('.loading-dots');

0 commit comments

Comments
 (0)