internetarchive / internetarchive/openlibrary
Book-unavailable banner: dismissal doesn't persist, and wording misleads for non-lendable books
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 138
Description
### Problem
The "This book is currently unavailable on Open Library…" banner on book pages has two issues:
1. **Dismissal doesn't persist** — clicking the X removes the banner, but it reappears on every page load. The `` has `dismissible` but no `dismiss-id`, so the site-level persistence layer (cookie via `/hide_banner`) never kicks in.
2. **Misleading wording** — the same "currently unavailable" copy is shown for all four lending states (`preview_only`, `checkedout`, `waitlist`, `locate`). For `preview_only`/`locate` the book will never be borrowable on Open Library, so "currently" wrongly implies it may become available soon.
### Reproducing the bug
1. Go to a book page for a non-lendable book, e.g. https://openlibrary.org/books/OL13424114M (Coming up for air)
2. Dismiss the banner via the X, then reload the page
* Expected behavior: dismissal persists (at least for a while); wording reflects whether unavailability is temporary
* Actual behavior: banner returns on every load; "currently unavailable" shown even for permanently non-lendable books
### Context
- Browser (Chrome, Safari, Firefox, etc): all
- OS (Windows, Mac, etc): all
- Logged in (Y/N): Y/N
- Environment (prod, dev, local): prod
### Breakdown
Implementation Details (for maintainers)
- Persistence: add a `dismiss-id` (e.g. per-edition, short TTL via `data-cookie-duration-days`) and guard rendering on the cookie in the template. Since the banner reflects live lending state, a short TTL or session-scoped dismissal is probably right — not a permanent one.
- Wording: branch the copy on `lending_state` — e.g. "This book isn't available to borrow on Open Library…" for `preview_only`/`locate`, keep "currently unavailable" for `checkedout`/`waitlist`.
#### Requirements Checklist
* [ ] Banner dismissal persists across reloads for a reasonable period
* [ ] Copy distinguishes temporarily vs. permanently unavailable books
#### Related files
* `openlibrary/macros/EditionNavBar.html` (banner markup + lending states)
* `openlibrary/components/lit/OlBanner.js` (component; owns no persistence)
* `openlibrary/plugins/openlibrary/js/banner/index.js` (dismiss-id → cookie glue)
#### Stakeholders
*
#### Instructions for Contributors
- Please [run these commands](https://docs.openlibrary.org/developers/tools/git.html#working-on-your-branch) to ensure your repository is up to date **before** [creating a new branch](https://docs.openlibrary.org/developers/tools/git.html#making-changes-and-creating-a-pull-request) 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.
Contributor guide
Assessment
This issue has not been assessed yet.