Skip to content

Fix: Preview button on homepage does nothing when clicked#11903

Merged
4 commits merged intointernetarchive:masterfrom
bhardwajparth51:fix/homepage-preview-button
Mar 11, 2026
Merged

Fix: Preview button on homepage does nothing when clicked#11903
4 commits merged intointernetarchive:masterfrom
bhardwajparth51:fix/homepage-preview-button

Conversation

@bhardwajparth51
Copy link
Copy Markdown
Contributor

Closes #11899

Technical

This fix implements the approach suggested by @mekarpeles in #11899,
with some additional improvements.

Root causes:

  1. The #bookPreview modal HTML was never rendered on the homepage
    since lazy carousels do not call the BookPreview macro server-side.
  2. initPreviewDialogs binds click handlers at page load, but carousel
    content is injected via AJAX afterward, so buttons never received handlers.

Changes:

  • index.html: Added $:macros.BookPreview('') to render modal HTML on
    page load so it is available when carousel buttons are clicked
  • dialog.js: Added context = document parameter to initPreviewDialogs
    and scoped selector to $(context).find('.cta-btn--preview').not('.cboxElement')
    to prevent double-binding on already initialized buttons
  • lazy-carousel.js: Import and call initPreviewDialogs(newElem) after
    AJAX carousel content is inserted into the DOM

Testing

  1. Go to https://openlibrary.org/
  2. Find a book on the homepage carousel with a "Preview" button
  3. Click the "Preview" button
  4. The Internet Archive book reader should open inline on the same page

Stakeholders

@mekarpeles @jimchamp @RayBB

@github-actions github-actions bot added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Feb 20, 2026
@bhardwajparth51
Copy link
Copy Markdown
Contributor Author

Hi @mekarpeles

Just a gentle follow-up on this PR since #11899 is marked Priority 1.
It implements the approach you suggested and keeps the changes minimal and scoped to the homepage preview behaviour.
It also looks like two workflows are awaiting maintainer approval -- would appreciate a quick look when you have bandwidth.
Happy to make any adjustments if needed. Thanks

@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Feb 24, 2026
Updated BookPreview macro to return a div element.
@bhardwajparth51
Copy link
Copy Markdown
Contributor Author

@RayBB @jimchamp all test cases are passing now. Would appreciate a review when you have bandwidth. Thanks

@mekarpeles mekarpeles added Priority: 2 Important, as time permits. [managed] and removed Priority: 1 Do this week, receiving emails, time sensitive, . [managed] labels Mar 6, 2026
@mekarpeles mekarpeles added this to the Sprint 2026-03 milestone Mar 6, 2026
@mekarpeles mekarpeles assigned lokesh and unassigned jimchamp Mar 6, 2026
@lokesh lokesh self-requested a review March 6, 2026 23:52
@mekarpeles mekarpeles closed this pull request by merging all changes into internetarchive:master in 47b9d59 Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead Priority: 2 Important, as time permits. [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Preview Button on Homepage Does Nothing When Clicked

4 participants