mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix typing in markdown input causing page scroll position changes
This commit is contained in:
parent
27af96fe3a
commit
2bb86c9e3b
1 changed files with 2 additions and 4 deletions
|
@ -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`;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue