Skip to content

Commit 07e3fa6

Browse files
Fixed Read More Button Display Logic to Avoid Unnecessary Display (#9959)
1 parent d5c66d5 commit 07e3fa6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

openlibrary/plugins/openlibrary/js/readmore.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ export class ReadMoreComponent {
5353

5454
reset() {
5555
this.fullHeight = this.$content.scrollHeight;
56+
if (this.$readMoreButton && this.$readMoreButton.offsetHeight) {
57+
this.readMoreHeight = this.$readMoreButton.offsetHeight;
58+
}
59+
const collapsedHeight = this.collapsedHeight;
60+
const readMoreButtonHeight = this.readMoreHeight || 0;
61+
5662
// Fudge factor to account for non-significant read/more
5763
// (e.g missing a bit of padding)
58-
if (this.$content.scrollHeight <= (this.collapsedHeight + 1)) {
64+
if (this.fullHeight <= (collapsedHeight + readMoreButtonHeight + 1)) {
5965
this.expand();
6066
this.$container.classList.add('read-more--unnecessary');
6167
} else {

0 commit comments

Comments
 (0)