Skip to content

Conversation

@cdrini
Copy link
Collaborator

@cdrini cdrini commented Jul 21, 2025

Closes #11018

Technical

Testing

Screenshot

Before After
image image
image image

Note there's still something off with the search ranking... see #10969 . But this should help non-English users find the book they want.

Stakeholders

@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 17.01%. Comparing base (e027195) to head (b91ade1).
Report is 292 commits behind head on master.

Files with missing lines Patch % Lines
openlibrary/plugins/openlibrary/js/SearchBar.js 0.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11047      +/-   ##
==========================================
- Coverage   17.14%   17.01%   -0.14%     
==========================================
  Files          91       92       +1     
  Lines        4981     5025      +44     
  Branches      867      876       +9     
==========================================
+ Hits          854      855       +1     
- Misses       3588     3623      +35     
- Partials      539      547       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cdrini cdrini marked this pull request as ready for review July 21, 2025 14:09
@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 14:09
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 enhances the autocomplete functionality to be edition-aware, improving the user experience by showing more relevant search results and linking to specific book editions rather than just works. The changes also include visual improvements to the autocomplete UI.

  • Makes autocomplete results display specific book editions instead of just works
  • Updates the link generation to include edition parameters when applicable
  • Improves visual styling with updated border radius, font sizes, and transitions
  • Adds high-resolution image support with srcset attributes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
static/css/components/header-bar.less Updates autocomplete styling with new border radius, font sizes, transitions, and layout improvements
openlibrary/plugins/openlibrary/js/SearchBar.js Implements edition-aware autocomplete logic, updates link generation, and adds high-resolution image support

Comment on lines 30 to 47
const book = work.editions?.docs?.[0] || work;
const author_name = work.author_name ? work.author_name[0] : '';
let link = `${work.key}/${encodeURIComponent(work.title.replace(/ /g, '_'))}`;
if (book !== work) {
link += `?edition=key:${book.key}`;
}
return `
<li tabindex=0>
<a href="${work.key}">
<img src="//covers.openlibrary.org/b/id/${work.cover_i}-S.jpg?default=https://openlibrary.org/static/images/icons/avatar_book-sm.png" alt=""/>
<a href="${link}">
<img
src="//covers.openlibrary.org/b/id/${book.cover_i}-S.jpg?default=https://openlibrary.org/static/images/icons/avatar_book-sm.png"
srcset="//covers.openlibrary.org/b/id/${book.cover_i}-M.jpg?default=https://openlibrary.org/static/images/icons/avatar_book-sm.png 2x"
alt=""
/>
<span class="book-desc">
<div class="book-title">${websafe(work.title)}</div><div class="book-subtitle">${websafe(work.subtitle)}</div> by <span class="book-author">${websafe(author_name)}</span>
<div class="book-title">${websafe(book.title)}</div>
<div class="book-subtitle">${websafe(book.subtitle)}</div>
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

The variable name 'book' is misleading since it could be either a book edition or a work object. Consider renaming to 'bookOrWork' or 'displayItem' to clarify that it represents the item being displayed, which may fallback to the work if no edition is available.

Copilot uses AI. Check for mistakes.

@cdrini cdrini force-pushed the feature/edition-aware-autocomplete branch from 1327afb to b91ade1 Compare July 21, 2025 14:19
@mekarpeles mekarpeles self-assigned this Jul 21, 2025
@github-actions github-actions bot added the Needs: Response Issues which require feedback from lead label Jul 22, 2025
@mekarpeles mekarpeles merged commit 104f8e9 into internetarchive:master Jul 24, 2025
3 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make search box autocomplete edition-aware

3 participants