Skip to content

Fix carousel retry link refreshing all carousels#11418

Merged
cdrini merged 1 commit intointernetarchive:masterfrom
jimchamp:lazy-carousel-regressions
Nov 5, 2025
Merged

Fix carousel retry link refreshing all carousels#11418
cdrini merged 1 commit intointernetarchive:masterfrom
jimchamp:lazy-carousel-regressions

Conversation

@jimchamp
Copy link
Collaborator

@jimchamp jimchamp commented Nov 5, 2025

Follows #11028

Fixes regressions annotated here and here.

Technical

Testing

Screenshot

Stakeholders

Copilot AI review requested due to automatic review settings November 5, 2025 00:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the lazy carousel JavaScript code to improve error handling and code quality. The changes eliminate jQuery usage in favor of vanilla JavaScript and add a null check for an optional DOM element.

Key Changes

  • Replaced jQuery event listener with vanilla JavaScript addEventListener for the retry button
  • Added null safety check for the .lazy-carousel-fallback element before manipulating its class list
  • Updated comment from plural "listeners" to singular "listener" to match the actual behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to 27
retryElem.addEventListener('click', (e) => {
e.preventDefault()
handleRetry(elem);
})
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential null dereference if .retry-btn element is not found. Add a null check before calling addEventListener, similar to the null check added for carouselFallbackElem in the handleRetry function.

Suggested change
retryElem.addEventListener('click', (e) => {
e.preventDefault()
handleRetry(elem);
})
if (retryElem) {
retryElem.addEventListener('click', (e) => {
e.preventDefault()
handleRetry(elem);
})
}

Copilot uses AI. Check for mistakes.
@cdrini cdrini changed the title Fix carousel lazy-load regressions Fix carousel retry link refreshing all carousels Nov 5, 2025
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Lgtm. Putting on testing now for a test, but code makes sense to me 👍

@cdrini
Copy link
Collaborator

cdrini commented Nov 5, 2025

Tried going offline midway through https://testing.openlibrary.org/collections/the_haunted_library , and confirmed the retry link only reloaded one carousel 👍

@cdrini cdrini merged commit 44b9fa1 into internetarchive:master Nov 5, 2025
10 checks passed
@jimchamp jimchamp deleted the lazy-carousel-regressions branch November 6, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants