| 703 | 703 | */ |
| 704 | 704 | function autoFitSendTextArea() { |
| 705 | 705 | const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight); |
| 706 | | - if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) { |
| 706 | + |
| 707 | | - const sendTextAreaMinHeight = '0px'; |
| 707 | + sendTextArea.style.height = '1px'; // Reset height to 1px to force recalculation of scrollHeight |
| 708 | | - sendTextArea.style.height = sendTextAreaMinHeight; |
| 708 | + const newHeight = sendTextArea.scrollHeight; |
| 709 | | - } |
| 710 | | - const newHeight = sendTextArea.scrollHeight + 3; |
| 711 | 709 | sendTextArea.style.height = `${newHeight}px`; |
| 712 | 710 | |
| 713 | 711 | if (!isFirefox) { |
| 714 | 712 | const newScrollTopchatBlock.scrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom)); |
| 715 | | - chatBlock.scrollTop = newScrollTop; |
| 716 | 713 | } |
| 717 | 714 | } |
| 718 | 715 | export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, debounce_timeout.short); |