Merge pull request #3006 from joenunezb/fix-textarea-width-bug

Fix: Inconsistent Textarea resizing in small width windows
This commit is contained in:
Cohee 2024-11-18 12:30:39 +02:00 committed by GitHub
commit 7aad053e70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 7 deletions

View File

@ -703,16 +703,13 @@ const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
*/
function autoFitSendTextArea() {
const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight);
if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) {
const sendTextAreaMinHeight = '0px';
sendTextArea.style.height = sendTextAreaMinHeight;
}
const newHeight = sendTextArea.scrollHeight + 3;
sendTextArea.style.height = '1px'; // Reset height to 1px to force recalculation of scrollHeight
const newHeight = sendTextArea.scrollHeight;
sendTextArea.style.height = `${newHeight}px`;
if (!isFirefox) {
const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom));
chatBlock.scrollTop = newScrollTop;
chatBlock.scrollTop = chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom);
}
}
export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, debounce_timeout.short);