| 703 | */ | 703 | */ |
| 704 | function autoFitSendTextArea() { | 704 | function autoFitSendTextArea() { |
| 705 | const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight); | 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 | sendTextArea.style.height = `${newHeight}px`; | 709 | sendTextArea.style.height = `${newHeight}px`; |
| 712 | | 710 | |
| 713 | if (!isFirefox) { | 711 | if (!isFirefox) { |
| 714 | const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom)); | 712 | chatBlock.scrollTop = chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom); |
| 715 | chatBlock.scrollTop = newScrollTop; | | |
| 716 | } | 713 | } |
| 717 | } | 714 | } |
| 718 | export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, debounce_timeout.short); | 715 | export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, debounce_timeout.short); |