From 568c1ba8ac84af67ba4ef6494f18715fc8949e68 Mon Sep 17 00:00:00 2001 From: Finn Bacall Date: Wed, 8 Apr 2026 09:56:33 +0100 Subject: [PATCH] Ensure expandable always expands to max height when opened. (Browser window might have been resized causing original clientHeight to no longer be the max height) --- app/assets/javascripts/application.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8e1fa6ff3..baebffef4 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -292,7 +292,7 @@ document.addEventListener("turbolinks:load", function(e) { return true; } this.dataset.origHeight = this.clientHeight; - this.style.maxHeight = '' + limit + 'px'; + this.style.maxHeight = '' + (limit - 50) + 'px'; this.classList.add('tess-expandable-closed'); const btn = $('Show more'); btn.insertAfter($(this)); @@ -379,13 +379,14 @@ $(document).on('click', '.tess-expandable-btn', function (event) { return false; } - const maxHeight = parseInt(div.dataset.origHeight) + 80; + const maxHeight = parseInt(div.dataset.origHeight) + 120; const limit = parseInt(div.dataset.heightLimit || "300"); if (div.classList.contains('tess-expandable-closed')) { div.classList.add('tess-expandable-open'); div.classList.remove('tess-expandable-closed'); div.style.maxHeight = '' + maxHeight + 'px'; + setTimeout(() => div.style.maxHeight = null, 500); this.innerHTML = 'Show less'; } else { div.classList.remove('tess-expandable-open');