Skip to content

Commit e651b08

Browse files
committed
Fixed typing in caused scroll
1 parent 8a86519 commit e651b08

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

popup-page-scripts/popup-page-customButtons.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,26 @@ function textareaInputAreaResizerFun(textareaId) {
396396
* Resizes a textarea vertically to fit its content.
397397
* @param {HTMLTextAreaElement} textarea The textarea to resize.
398398
*/
399+
/**
400+
* Resizes a textarea vertically to fit its content while preserving the scroll position.
401+
* This prevents the page from scrolling when the textarea is resized.
402+
* @param {HTMLTextAreaElement} textarea The textarea to resize.
403+
*/
399404
function resizeVerticalTextarea(textarea) {
400405
if (!textarea) return;
406+
407+
// Save current scroll position
408+
const scrollPos = {
409+
top: window.pageYOffset || document.documentElement.scrollTop,
410+
left: window.pageXOffset || document.documentElement.scrollLeft
411+
};
412+
413+
// Perform resize
401414
textarea.style.height = 'auto';
402415
textarea.style.height = `${textarea.scrollHeight}px`;
416+
417+
// Restore scroll position
418+
window.scrollTo(scrollPos.left, scrollPos.top);
403419
}
404420

405421
/**

0 commit comments

Comments
 (0)