feat(ui): collapse long messages with Show more / Show less (LC-256) #306
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-256-collapse-long-messages"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Folds messages whose rendered body overflows a height threshold behind a "Show more" / "Show less" toggle (LC-256), so a pasted log or wall of text no longer takes over the viewport.
How
server/templates/room/message.html: the full Markdown body still renders; it just gains adata-lc-collapsemarker and ahiddendata-lc-collapse-togglebutton (with localizeddata-lc-more/data-lc-less). No clamp is applied server-side.server/assets/main.css:.lc-collapsibleclampsmax-heightto20remwithoverflow:hiddenand a non-interactive bottom fade to--surface.server/templates/partials/auto_scroll.html: aprocessCollapse(scope)pass measures each unprocessed body's naturalscrollHeight; only when it exceeds420pxdoes it add the clamp and reveal the toggle (which toggles the class + label). Runs on initial paint (before scroll anchoring, so clamped heights settle), onhtmx:afterSwap(edited re-render, re-measured), and onhtmx:oobAfterSwap(live append folded before re-anchoring). Idempotent via a-donemarker; the body-level listener is torn down with the existing autoscroll teardown.server/locales/{en,es}/room.ftl:room-msg-show-more/room-msg-show-less.Progressive enhancement: with JS off the full body renders (nothing hidden from no-JS clients or crawlers). Collapse applies to the Markdown body only, not attachments / polls / reactions.
The four LC-77 golden render fixtures are regenerated for the new body markup (diff is exactly the added marker + toggle).
Pure front-end: no route, DB, or env change. Not operator-visible.
Tests
routes_drafts::message_body_ships_collapse_markupasserts a seeded message ships the marker + toggle.just testandjust test-saaspass.QA note
The fold is JS-measured and the toggle is JS-driven, so they want a quick manual click-through before merge: post a very long message (confirm it clamps with a fade + "Show more"); expand/collapse it; confirm a short message shows no toggle; confirm a long message arriving live over the WS folds while you are scrolled to the bottom; confirm an edit that makes a message long/short updates the fold. Tune the
420pxthreshold if it fires on normal multi-line messages.