openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Fixed Read More Button Display Logic to Avoid Unnecessary Display

Open CodeMaverick2 opened this issue 1 year ago • 8 comments

Closes #9329

Description

This PR addresses an issue where the "Read more" button was displayed even when it made the section longer than the fully expanded content. This led to a confusing user experience, as the "Read more" button was not serving its intended purpose. The following changes have been made to resolve this issue:

Changes

  1. Capture "Read More" Button Height:

    • The height of the "Read more" button is now captured during initialization to ensure accurate calculations.
  2. Update Condition in reset Method:

    • The logic that determines whether the "Read more" button should be displayed has been updated to include the height of the button. This ensures the button is only shown when it makes sense.

Impact

  • Improved User Experience: The "Read more" button is now only displayed when necessary, preventing unnecessary clutter and confusion.
  • Correct Layout Behavior: Ensures the layout behaves as expected, with the "Read more" button enhancing usability rather than detracting from it.

Testing

To test visit a link like https://testing.openlibrary.org/books/OL8978501M/Robin_Hood

Screenshots

Screenshot from 2024-07-25 18-43-42

CodeMaverick2 avatar Sep 11 '24 20:09 CodeMaverick2

@RayBB I have done the changes recommended by @cdrini

CodeMaverick2 avatar Sep 11 '24 20:09 CodeMaverick2

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 16.42%. Comparing base (ce16a79) to head (90a10f0). Report is 399 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9871      +/-   ##
==========================================
+ Coverage   16.06%   16.42%   +0.36%     
==========================================
  Files          90       92       +2     
  Lines        4769     4907     +138     
  Branches      832      856      +24     
==========================================
+ Hits          766      806      +40     
- Misses       3480     3565      +85     
- Partials      523      536      +13     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Sep 12 '24 00:09 codecov-commenter

@RayBB Sure, @cdrini Can u check the problem

CodeMaverick2 avatar Sep 15 '24 18:09 CodeMaverick2

@RayBB Are there any more changes that need to be done in this

CodeMaverick2 avatar Sep 19 '24 08:09 CodeMaverick2

We are waiting for staff to review. They often do this on Monday. If not feel free to tag @cdrini again

RayBB avatar Sep 19 '24 08:09 RayBB

@cdrini What's the status here ?

CodeMaverick2 avatar Sep 23 '24 20:09 CodeMaverick2

@RayBB @cdrini The tests are failing like previously not able to figure out why

CodeMaverick2 avatar Sep 26 '24 16:09 CodeMaverick2

Nice! There's still the first point; we'll want to fetch the height value only once (see the first bullet point)

Oh the tests are failing cause it looks readMoreButton is null in the tests; You'll need to update the test so that it is not null :+1:

cdrini avatar Sep 27 '24 19:09 cdrini