From 9c46396a39a3ccf9fdc15689de65f4dc19ce4cb3 Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Fri, 22 May 2026 08:09:41 +0200 Subject: [PATCH] attempting to fix mobile replies/quotes --- public/s/js/comments.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/public/s/js/comments.js b/public/s/js/comments.js index 50cd00e..66c3c44 100644 --- a/public/s/js/comments.js +++ b/public/s/js/comments.js @@ -1049,10 +1049,28 @@ class CommentSystem { textarea.focus({ preventScroll: true }); textarea.selectionStart = textarea.selectionEnd = textarea.value.length; textarea.dispatchEvent(new Event('input', { bubbles: true })); + this._scrollReplyIntoView(textarea); } } } + _scrollReplyIntoView(textarea) { + const form = textarea.closest('.reply-input'); + if (!form) return; + + // Smooth scroll immediately + form.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); + + // On mobile, the virtual keyboard takes a moment to appear and resizes the viewport. + // Doing a delayed scroll guarantees it is centered and fully visible within the resized viewport. + if (window.innerWidth <= 768) { + setTimeout(() => { + form.scrollIntoView({ behavior: 'smooth', block: 'center' }); + }, 300); + } + } + + saveMediaState() { // Snapshot currently playing or paused-mid-way media elements const state = []; @@ -2612,6 +2630,7 @@ class CommentSystem { textarea.focus({ preventScroll: true }); textarea.selectionStart = textarea.selectionEnd = start + quote.length; textarea.dispatchEvent(new Event('input', { bubbles: true })); + this._scrollReplyIntoView(textarea); } } return;