| 881 | saveSettingsDebounced(); | 881 | saveSettingsDebounced(); |
| 882 | }); | 882 | }); |
| 883 | | 883 | |
| 884 | $(sendTextArea).on('input', () => { | 884 | sendTextArea.addEventListener('input', () => { |
| 885 | const scrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth && sendTextArea.offsetHeight >= window.innerHeight / 2; | 885 | const hasContent = sendTextArea.value !== ''; |
| 886 | if ((sendTextArea.scrollHeight > sendTextArea.offsetHeight && !scrollbarShown) || sendTextArea.value === '') { | 886 | const fitsCurrentSize = sendTextArea.scrollHeight <= sendTextArea.offsetHeight; |
| 887 | autoFitSendTextArea(); | 887 | const isScrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth; |
| 888 | } else { | 888 | const isHalfScreenHeight = sendTextArea.offsetHeight >= window.innerHeight / 2; |
| 889 | autoFitSendTextAreaDebounced(); | 889 | const needsDebounce = hasContent && (fitsCurrentSize || (isScrollbarShown && isHalfScreenHeight)); |
| 890 | } | 890 | if (needsDebounce) autoFitSendTextAreaDebounced(); |
| | 891 | else autoFitSendTextArea(); |
| 891 | saveUserInputDebounced(); | 892 | saveUserInputDebounced(); |
| 892 | }); | 893 | }); |
| 893 | | 894 | |