attempting to fix mobile replies/quotes
This commit is contained in:
@@ -1049,10 +1049,28 @@ class CommentSystem {
|
|||||||
textarea.focus({ preventScroll: true });
|
textarea.focus({ preventScroll: true });
|
||||||
textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
|
textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
|
||||||
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
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() {
|
saveMediaState() {
|
||||||
// Snapshot currently playing or paused-mid-way media elements
|
// Snapshot currently playing or paused-mid-way media elements
|
||||||
const state = [];
|
const state = [];
|
||||||
@@ -2612,6 +2630,7 @@ class CommentSystem {
|
|||||||
textarea.focus({ preventScroll: true });
|
textarea.focus({ preventScroll: true });
|
||||||
textarea.selectionStart = textarea.selectionEnd = start + quote.length;
|
textarea.selectionStart = textarea.selectionEnd = start + quote.length;
|
||||||
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
this._scrollReplyIntoView(textarea);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user