From 55082ce248954dfa61a0e53a48fdc2c9a26a09cb Mon Sep 17 00:00:00 2001 From: Tejas Ghatule <141946130+CodeMaverick2@users.noreply.github.com> Date: Tue, 22 Oct 2024 04:08:12 +0000 Subject: [PATCH] Fixed Read More Button Display Logic to Avoid Unnecessary Display --- openlibrary/plugins/openlibrary/js/readmore.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openlibrary/plugins/openlibrary/js/readmore.js b/openlibrary/plugins/openlibrary/js/readmore.js index 37f9fd03341..6d2d68e17bd 100644 --- a/openlibrary/plugins/openlibrary/js/readmore.js +++ b/openlibrary/plugins/openlibrary/js/readmore.js @@ -52,10 +52,13 @@ export class ReadMoreComponent { } reset() { - this.fullHeight = this.$content.scrollHeight; + const fullHeight = this.$content.scrollHeight; + const collapsedHeight = this.collapsedHeight; + const readMoreButtonHeight = this.$readMoreButton ? this.$readMoreButton.offsetHeight : 0; + // Fudge factor to account for non-significant read/more // (e.g missing a bit of padding) - if (this.$content.scrollHeight <= (this.collapsedHeight + 1)) { + if (fullHeight <= (collapsedHeight + readMoreButtonHeight + 1)) { this.expand(); this.$container.classList.add('read-more--unnecessary'); } else {