New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix scroll issues for textarea on divs with overflow #298
fix scroll issues for textarea on divs with overflow #298
Conversation
The commit fixes scroll issues with textarea which are on a div with overflow. autosize is changing scrollTop of the parent div during update after text height. In result textarea is jumping when using is typing something in the field. The problem is significant for bigger texts.
It seems the compiled js didn't get committed ( |
…verflow-missing-dist Adding missing dist files
I've added missing dist files. The fix works in our application pretty well. I'm also hoping for quick merge of the fix, since then I could remove fork from our app. |
Thanks! That's working great for nested textareas, but it looks like it breaks when there is no parent with I think while(element.parentNode) {
element = element.parentNode;
if(element === document) { // there is no overflow parent
return null;
} else {
var elementStyle = window.getComputedStyle(element, null);
var overflowValue = elementStyle.getPropertyValue('overflow-y');
if (overflowValue === 'auto') {
return element;
}
}
} |
Ah, that's true. In our project we don't have this case. Here's a fix, similar to what you proposed. |
I'm using the fork in my project too, now, and it's working great. Thanks @mst-avaleo! |
Thanks @mst-avaleo. My apologies for the late response to your pull request. I think you did a good job, but there was a couple of things I wanted to do a little different. I committed an alternative fix for this using your code as a guide, let me know how it works for you. |
I worried about the performance impact of calling getComputedStyle on every ancestor node, so I replaced that with just a check for the scrollTop value, since that was what was actually needed. Since changing the height of the textarea element may impact the overflow of more than one parent element, I changed it to restore the overflow for all ancestor elements (which removed the need to specifically target document.body). |
It works like my fix, so I'll switch to official 3.0.16. Thanks for the final fix! |
👍 Thank you |
The commit fixes scroll issues with textarea which are on a div with overflow. autosize is changing scrollTop of the parent div during update after text height. In result textarea is jumping when using is typing something in the field. The problem is significant for bigger texts.