From 2bb86c9e3bcc557bfa67dd859549ab127162d601 Mon Sep 17 00:00:00 2001 From: SeinopSys Date: Fri, 1 Oct 2021 00:43:04 +0200 Subject: [PATCH] fix typing in markdown input causing page scroll position changes --- assets/js/preview.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/assets/js/preview.js b/assets/js/preview.js index 757ef52b..2932489b 100644 --- a/assets/js/preview.js +++ b/assets/js/preview.js @@ -61,15 +61,13 @@ function getPreview(body, anonymous, previewLoading, previewIdle, previewContent * @param {E} e */ function resizeTextarea(e) { - // Reset inline height for fresh calculations - e.target.style.height = ''; const { borderTopWidth, borderBottomWidth, height } = window.getComputedStyle(e.target); // Add scrollHeight and borders (because border-box) to get the target size that avoids scrollbars const contentHeight = e.target.scrollHeight + parseFloat(borderTopWidth) + parseFloat(borderBottomWidth); // Get the original default height provided by page styles - const regularHeight = parseFloat(height); + const currentHeight = parseFloat(height); // Limit textarea's size to between the original height and 1000px - const newHeight = Math.max(regularHeight, Math.min(1000, contentHeight)); + const newHeight = Math.max(currentHeight, Math.min(1000, contentHeight)); e.target.style.height = `${newHeight}px`; }