fix: account for button height in read-more truncation threshold - #13059
Merged
lokesh merged 3 commits intoJun 30, 2026
Conversation
Collaborator
|
Verified locally. LGTM! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13052
fix
Implements a robust line height buffer-based approach for the
ol-read-morecomponent's truncation logic. This replaces the fragile, absolute height-based truncation checks, ensuring the "Read More" toggle button only displays when collapsing the content saves a meaningful amount of vertical space.Technical
_checkIfTruncationNeeded()inopenlibrary/components/lit/OLReadMore.jsto calculate overflow thresholds using line-height multiples rather than absolute pixel bounds.static BUFFER_LINES = 5to represent the line buffer. The component only collapses if the hidden height would exceed the visible collapsed height by more than 5 lines (BUFFER_LINES). If collapsing the content would hide 5 lines or less, it is displayed fully with the toggle button hidden, ensuring the collapse always "earns its place"._getLineHeight(el)to dynamically resolve the computed line-height of the assigned slotted elements, falling back gracefully tofontSize * 1.5if the CSSline-heightevaluates tonormal.openlibrary/components/lit/custom-elements.json) to reflect the new component properties.Testing
<ol-read-more max-height="80px">component inopenlibrary/templates/design.htmllocally (or view any short/medium book description on/books/OL24620876M).