jackmoore/autosize

Bug with scroll-behavior: smooth

dev1z opened this issue · 2 comments

dev1z commented

@jackmoore There is currently a bug with bootstrap 5 and implementation of scroll smoothing, any idea how to fix it?

twbs/bootstrap#33910

@dev1z Thanks, I left a comment. I doubt it's fixable if using smooth scrolling because of the approach that autosize takes to computing the height change. There are other approaches for getting the height calculation (such as having a mirror textarea element offscreen), but that would be a very different script than what Autosize currently is and isn't without its own, different, pitfalls. Sorry for the trouble.

Adding the following code solved the problem.
What about the idea of temporarily disabling smooth scrolling?

Beginning of resize() function

    const html = document.querySelector('html');
    html.style.scrollBehavior = "auto";

End of resize() function

html.style.scrollBehavior = null;