Fix: Hide loading indicator if carousel loading fails.#11389
Fix: Hide loading indicator if carousel loading fails.#11389jimchamp merged 3 commits intointernetarchive:masterfrom
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull Request Overview
This PR adds defensive null-checking before hiding the loading indicator in the error handler of the lazy carousel functionality. This prevents potential runtime errors when the loading indicator element doesn't exist.
- Added null check for
loadingIndicatorin the catch block before attempting to hide it
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (loadingIndicator){ | ||
| loadingIndicator.classList.add('hidden'); | ||
| } |
There was a problem hiding this comment.
| if (loadingIndicator){ | |
| loadingIndicator.classList.add('hidden'); | |
| } | |
| loadingIndicator.classList.add('hidden'); |
loadingIndicator will exist, and is accessed in the previous then call. No need for the if statement here.
There was a problem hiding this comment.
That is to say: This will always be true regardless of the element being hidden.
jimchamp
left a comment
There was a problem hiding this comment.
Thanks @SAYAN02-DEV.
As things are today, your if condition will always be true. Please remove it.
| if (loadingIndicator){ | ||
| loadingIndicator.classList.add('hidden'); | ||
| } |
There was a problem hiding this comment.
That is to say: This will always be true regardless of the element being hidden.
Co-authored-by: jimchamp <28732543+jimchamp@users.noreply.github.com>
|
@jimchamp I got it and removed the |
Closes #11380
fix: This feature hides the carousel loading indicator if carousel loading fails.
Technical
In openlibrary/openlibrary/plugins/openlibrary/js/lazy-carousel.js in catch block I added a condition to check if
loadingIndicatoris visible a thenloadingIndicator.classList.add('hidden');hides the loadingIndicator.
Screenshot
before:


after: