Carousel stops working after loading one page of results
Problem
I encountered this issue on a subject page, after clicking the arrow to load the second set of results the carousel repopulates but then stops working and no longer responds to clicks on either directional arrow for loading the previous or next set of results.
See: https://openlibrary.org/subjects/roof_gardening
https://github.com/user-attachments/assets/54d3c242-cb70-4827-8cac-a1032f38e992
Console shows the following error:
Uncaught TypeError: can't access property "loading", this.i18n is undefined
Reproducing the bug
- Go to a subject page and interact with the carousel, e.g. https://openlibrary.org/subjects/roof_gardening
- Click the right-facing arrow to load the next set of works. The works should load but now the carousel is in a non-functional state, no further works will load and you cannot go back to the first set of works either.
- Expected behavior:
The carousel should allow the patron (user) to browse forward and backwards through all the works.
- Actual behavior:
The carousel works initially but the fails after the first additional "page" of results is loaded.
Context
- Browser (Chrome, Safari, Firefox, etc): Firefox
- OS (Windows, Mac, etc): Linux
- Logged in (Y/N): Y
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
- [ ]
Related files
Stakeholders
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
Thank you @agmckee for submitting this issue!
⚠️ Contributors, this issue will be ready to work on once:
- [ ] Triage — maintainers will add
Priority: *andLead: @*to replaceNeeds: TriageandNeeds: Lead
Context
The console error (Uncaught TypeError: can't access property "loading", this.i18n is undefined) maps directly to a known bug in openlibrary/plugins/openlibrary/js/carousel/Carousel.js. On construction, the carousel queries a hidden input[name="carousel-i18n-strings"] element; if that element is absent, this.i18n is never initialized. appendLoadingSlide() (called when the next page triggers) then tries this.i18n['loading'] and throws.
This root cause was reported previously as #12714 (closed 2026-05-29) and addressed in PR #12812 (merged 2026-05-29), which added two fixes to Carousel.js:
- A default
this.i18n = {loading: ''}before the conditional input read, preventing the crash when the input is absent. - A
.fail()handler on the AJAX request to releaseloadMore.lockedon network errors.
This issue was opened on 2026-06-03, five days after the fix merged. The behavior being reported suggests either the fix has not yet been deployed to production, or there is a separate code path — possibly a carousel rendered without going through custom_carousel.html (which contains the i18n input) — that still hits the unfixed state.
The subject page (templates/subjects.html) renders its carousel via the QueryCarousel macro, which eventually calls custom_carousel.html. The template uses render_once('books/custom_carousel.i18n-strings') to emit the i18n input at most once per page; if multiple carousel instances share a page, only one input is written, but the JS querySelector finds it either way. No obvious template-level gap was found.
Issue Assessment
Open questions
- Has PR #12812 been deployed to production? If so, can the reporter confirm whether the issue persists after a hard refresh (to rule out a cached JS bundle)?
- Is the carousel on
/subjects/roof_gardeningrendered through a path that includescustom_carousel.html, or is it a lazy/partial load that may bypass that template?
Action items
- [ ] Confirm whether PR #12812 resolves this; if so, close as duplicate of #12714.
- [ ] If the bug persists post-deploy, identify which carousel render path is missing the
carousel-i18n-stringsinput and apply the same fix.
Full triage checklist (maintainers / Pam)
- [x] Triage —
Needs: Breakdownremoved (not appropriate for a bug with a known fix);Module: CarouselsandModule: JavaScriptadded;Needs: TriageandNeeds: Leadremain - [x] Problem / opportunity — problem is clear, audience identified, actionable
- [x] Scope — single, well-scoped bug
- [x] Justification — carousel is non-functional after first page load; blocks browsing subject works
- [ ] Success & testing criteria — not explicitly stated; implied: carousel navigates forward and backward indefinitely without freezing
- [ ] Proposal & breakdown — no implementation plan from author; fix already exists in PR #12812
- [x] If bug: environment & repro steps — browser (Firefox/Linux), logged in, production, steps provided, video attached
- [x] Risks, concerns, open questions — deployment lag vs. separate code path; surfaced above
- [x] Pam context — #12714, PR #12812,
Carousel.jsconstructor andappendLoadingSlide()reviewed;custom_carousel.htmlandQueryCarousel.htmlreviewed - [x] References — screen recording and console error provided
cc @cdrini
[!NOTE] This comment was automatically generated by Pam, Open Library's Project AI Manager, on behalf of @mekarpeles. Pam is designed to provide status visibility, perform basic project management functions and relevant codebase research, and provide actionable feedback so contributors aren't left waiting.
I've reviewed the issue and PR #12812 — it looks like the this.i18n object is still not initialized in the load-more code path that gets triggered on the second navigation click. I'll add a defensive initialization guard in Carousel.js and add a regression test to cover this path.
Might be the fix in #12812 likely guarded i18n.loading in the initial setup path, but there's still a code path in Carousel.js — triggered when the user clicks the arrow a second time — where this.i18n itself was never initialized
Hi. PR #12812 has not yet been deployed to production.