internetarchive / openlibrary

One webpage for every book ever published!

Home Page:https://openlibrary.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Read more" button should not be added if it takes up as much space as the hidden text

cdrini opened this issue · comments

Problem

Evidence / Screenshot

image
image

Relevant URL(s)

E.g. https://openlibrary.org/books/OL8978501M/Robin_Hood

Reproducing the bug

  1. Go to https://openlibrary.org/books/OL8978501M/Robin_Hood
  • Expected behavior: Description not collapsed, since "read more" makes the section actually longer :P
  • Actual behavior: "Read more" shown over description

Context

  • Browser (Chrome, Safari, Firefox, etc): FF
  • OS (Windows, Mac, etc): Win
  • Logged in (Y/N): Y
  • Environment (prod, dev, local): prod

Notes from this Issue's Lead

Proposal & constraints

Perhaps we can update the + 1 here:

if (this.$content.scrollHeight <= (this.collapsedHeight + 1)) {

To instead be the height of the .read-more__toggle--more button. We might need to capture that height in the constructor though, before the read more button is potentially hidden!

Related files

https://github.com/internetarchive/openlibrary/blob/73b70f6b997c401caf2fe8078a6296c8f3167ee5/openlibrary/plugins/openlibrary/js/readmore.js

Stakeholders

@RayBB

Note: Before making a new branch or updating an existing one, please ensure your branch is up to date.