diff --git a/conversations.php b/conversations.php index 7e3fb30..d11724c 100644 --- a/conversations.php +++ b/conversations.php @@ -246,6 +246,15 @@ transition: opacity 0.12s ease-in-out; white-space: nowrap; } + + /* Preserve user whitespace and line breaks like WhatsApp */ + .message-content { + white-space: pre-wrap; /* preserve newlines and wrap long lines */ + white-space: -moz-pre-wrap; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + word-break: break-word; + } .message-bubble:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(2,6,23,0.06); @@ -2224,7 +2233,7 @@ const prependEls = []; // elements to insert at top if we loaded older messages - const nearBottom = (container.scrollHeight - container.scrollTop - container.clientHeight) < 150; + // calculate near-bottom late to decide scrolling after DOM updates (avoids stale value) for (let i = 0; i < this.conversations.length; i++) { const msg = this.conversations[i];