Shrink long comments instead of growing the comment box
CI / Deploy / test (push) Successful in 1m0s
CI / Deploy / deploy (push) Skipped

The comment box is capped at about five lines (--comment-max). A comment
that does not fit is set smaller step by step (Comments.fit(), also on
resize) instead of being cut off or pushing the slide off screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 13:55:48 +01:00
1 parent bbe3dfcc8e
commit b5ea4e70c8
3 files changed
+32 -2

No files matched your search

+4 -1
View File
@@ -582,7 +582,7 @@ button.qa-steps__step:hover:not(:disabled) { color: var(--text); border-color: v
.own-comment__edit summary:hover { color: var(--text); }
.comments { margin-top: 20px; padding: 16px 20px; background: var(--surface-2); border-radius: 14px; }
.comments__counter { margin: 0 0 6px; font-size: .85em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.comments__text { margin: 0; font-size: 1.25em; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
.comments__text { margin: 0; font-size: var(--comment-size); font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
.comments__text::before { content: '„'; }
.comments__text::after { content: '“'; }
.comments__value { margin: 6px 0 0; color: var(--muted); font-size: .9em; }
@@ -590,6 +590,9 @@ button.qa-steps__step:hover:not(:disabled) { color: var(--text); border-color: v
.comments__body { display: grid; }
.comments__body > * { grid-area: 1 / 1; min-width: 0; }
.comments__sizer { visibility: hidden; }
/* at most about 5 lines; longer comments are set smaller by Comments.fit() instead of being cut off */
.comments { --comment-size: 1.25em; --comment-max: 11em; }
.comments__sizer, .comments__current { max-height: var(--comment-max); overflow: hidden; }
.comments__progress { height: 4px; margin-top: 14px; border-radius: 2px; background: var(--border); overflow: hidden; }
.comments__progress[hidden] { display: block; visibility: hidden; } /* keeps the layout steady while paused */
.comments__progress-fill { height: 100%; background: var(--primary); transform: scaleX(0); transform-origin: left; }
+27
View File
@@ -392,6 +392,29 @@
return node;
},
/**
* The box has a maximum height (CSS --comment-max); a comment that does not fit is set
* smaller step by step instead of being cut off. The invisible sizers are capped the same
* way, so a single long comment does not make the box huge.
*/
fit: function () {
var node = Comments.node;
if (!node || !document.body.contains(node)) {
return;
}
var current = node.querySelector('.comments__current');
var text = node.querySelector('[data-comment-text]');
var size = 1;
text.style.fontSize = '';
while (current.scrollHeight > current.clientHeight + 1 && size > Comments.MIN_FONT) {
size = Math.max(Comments.MIN_FONT, size - 0.05);
text.style.fontSize = 'calc(' + size + ' * var(--comment-size))';
}
},
// Smallest font size (factor) for a long comment.
MIN_FONT: 0.5,
step: function (delta) {
var n = Comments.items.length;
Comments.index = (Comments.index + delta + n) % n;
@@ -472,6 +495,8 @@
void text.offsetWidth; // restart the CSS animation
text.classList.add('is-entering');
}
// Measure once the box is in the document (render() calls this before it is attached).
requestAnimationFrame(Comments.fit);
var toggle = node.querySelector('[data-comment-action="toggle"]');
if (toggle) {
var label = Comments.paused ? 'Kommentare automatisch weiterblättern' : 'Automatisches Weiterblättern anhalten';
@@ -483,6 +508,8 @@
Comments.progress();
}
};
// A different width changes the line breaks: fit the comment again.
window.addEventListener('resize', function () { Comments.fit(); });
// ------------------------------------------------------------------ results