fix: preserve scroll position in Textarea resize to prevent page jump on focus

This commit is contained in:
Ansh1372 2026-04-28 23:07:55 +05:30
parent 8dae237a0b
commit 9359dd0fd6

View file

@ -35,6 +35,9 @@
const resize = () => {
if (textareaElement) {
// Preserve scroll position to prevent page jumping to top on focus/resize
const scrollY = window.scrollY;
textareaElement.style.height = '';
let height = textareaElement.scrollHeight;
@ -46,6 +49,9 @@
}
textareaElement.style.height = `${height}px`;
// Restore scroll position after height recalculation
window.scrollTo({ top: scrollY, behavior: 'instant' });
}
};
</script>