From 9c9530e8c992b56900d8f81fa6ec6fa4a5788682 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Thu, 16 Jul 2026 19:41:30 +0200 Subject: [PATCH] h --- public/s/css/f0ckm.css | 9 ++++++++- public/s/js/sidebar-activity.js | 11 +++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/public/s/css/f0ckm.css b/public/s/css/f0ckm.css index 19d77c5..b973318 100644 --- a/public/s/css/f0ckm.css +++ b/public/s/css/f0ckm.css @@ -1996,7 +1996,14 @@ body.layout-modern .global-sidebar-right { margin-top: 5px; font-size: 0.85em; display: none; - /* Hidden by default, shown via JS if overflow detected */ + /* Hidden by default; CSS below shows it when has-overflow is present */ +} + +/* Show the button via CSS when the parent has has-overflow (set in the HTML template). + This avoids depending on JS timing — the button is visible from the very first paint. + JS checkOverflow() will later REMOVE has-overflow from short comments to hide it. */ +.sidebar-activity .comment-content.has-overflow > .read-more-btn { + display: block; } diff --git a/public/s/js/sidebar-activity.js b/public/s/js/sidebar-activity.js index 81a0e1b..c7fec29 100644 --- a/public/s/js/sidebar-activity.js +++ b/public/s/js/sidebar-activity.js @@ -542,17 +542,21 @@ }); }); - // Write phase: perform DOM updates after all reads are completed + // Write phase: perform DOM updates after all reads are completed. + // Visibility of the button is controlled entirely by the CSS rule on + // .comment-content.has-overflow > .read-more-btn — no btn.style.display here. results.forEach(({ container, btn, isExpanded, scrollHeight, clientHeight, hasUnloadedImages }) => { + // Clear any leftover inline display style (e.g. from the HTML template's + // style="display:block") so the CSS class-based rule is the single source of truth. + btn.style.display = ''; + if (isExpanded) { - btn.style.display = 'block'; btn.textContent = window.f0ckI18n?.sidebar_see_less || 'see less'; return; } if (scrollHeight > clientHeight + 2) { // 2px buffer for rounding // Content overflows — ensure clamped state (may already be set from HTML default) - btn.style.display = 'block'; btn.textContent = window.f0ckI18n?.sidebar_read_more || 'read more'; container.classList.add('has-overflow'); } else if (hasUnloadedImages) { @@ -561,7 +565,6 @@ // re-run checkOverflow once images finish loading. } else { // Content fits and all images are loaded — safe to remove clamped state - btn.style.display = 'none'; container.classList.remove('has-overflow'); } });