-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Read More Button Display Logic to Avoid Unnecessary Display #9871
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodeMaverick2 I pushed up a small change so that the tests pass and shouldn't impact functionality. Otherwise this looks good.
Unfortunately, my deploys to testing seem to be failing and I'm not sure why.
However, I've deployed it to gitpod and it's working for me.
Lets just get a final check from @cdrini
@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 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small bug, otherwise looking great! 😊
@@ -55,7 +55,7 @@ export class ReadMoreComponent { | |||
this.fullHeight = this.$content.scrollHeight; | |||
// Fudge factor to account for non-significant read/more | |||
// (e.g missing a bit of padding) | |||
if (this.$content.scrollHeight <= (this.collapsedHeight + 1)) { | |||
if (this.$content.scrollHeight <= (this.collapsedHeight + (this.$readMoreButton?.offsetHeight | 0) + 1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice this is working almost perfectly ! A few tweaks:
-
We'll want to compute and store the offsetHeight of the readMore button the first time reset is called. Otherwise when the read more button is hidden and
reset
is called, it will switch between existing and not existing. (You can observe this by trying to resize the window on testing. You'll see the read more button appear and disappear, since sometimes the height is there and sometimes it's zero). The first time reset is called, the read more is always visible, so you can likely do something like:this.readMoreHeight = this.readMoreHeight || this.$readMoreButton.offsetHeight;
at the top of this method. -
Also we don't need the
?.
since it's always defined, and we don't need to default to zero sinceoffsetHeight
will always be a valid number. -
(also: Small typo, I think you mean
||
instead of|
😁 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing that out—I’ve just fixed it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to implement that first bullet point as well!
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 |
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:
Update Condition in
reset
Method:Impact
Testing
To test visit a link like https://testing.openlibrary.org/books/OL8978501M/Robin_Hood
Screenshots