openlibrary
openlibrary copied to clipboard
Fixed Read More Button Display Logic to Avoid Unnecessary Display
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
-
Capture "Read More" Button Height:
- The height of the "Read more" button is now captured during initialization to ensure accurate calculations.
-
Update Condition in
resetMethod:- 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
@RayBB I have done the changes recommended by @cdrini
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.
@RayBB Sure, @cdrini Can u check the problem
@RayBB Are there any more changes that need to be done in this
We are waiting for staff to review. They often do this on Monday. If not feel free to tag @cdrini again
@cdrini What's the status here ?
@RayBB @cdrini The tests are failing like previously not able to figure out why
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: