| 916 | } | 916 | } |
| 917 | | 917 | |
| 918 | sendTextArea.addEventListener('input', () => { | 918 | sendTextArea.addEventListener('input', () => { |
| 919 | if (!cssAutofit) { | | |
| 920 | const hasContent = sendTextArea.value !== ''; | | |
| 921 | const fitsCurrentSize = sendTextArea.scrollHeight <= sendTextArea.offsetHeight; | | |
| 922 | const isScrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth; | | |
| 923 | const isHalfScreenHeight = sendTextArea.offsetHeight >= window.innerHeight / 2; | | |
| 924 | const needsDebounce = hasContent && (fitsCurrentSize || (isScrollbarShown && isHalfScreenHeight)); | | |
| 925 | if (needsDebounce) autoFitSendTextAreaDebounced(); | | |
| 926 | else autoFitSendTextArea(); | | |
| 927 | } | | |
| 928 | saveUserInputDebounced(); | 919 | saveUserInputDebounced(); |
| | 920 | |
| | 921 | if (cssAutofit) { |
| | 922 | return; |
| | 923 | } |
| | 924 | |
| | 925 | const hasContent = sendTextArea.value !== ''; |
| | 926 | const fitsCurrentSize = sendTextArea.scrollHeight <= sendTextArea.offsetHeight; |
| | 927 | const isScrollbarShown = sendTextArea.clientWidth < sendTextArea.offsetWidth; |
| | 928 | const isHalfScreenHeight = sendTextArea.offsetHeight >= window.innerHeight / 2; |
| | 929 | const needsDebounce = hasContent && (fitsCurrentSize || (isScrollbarShown && isHalfScreenHeight)); |
| | 930 | if (needsDebounce) autoFitSendTextAreaDebounced(); |
| | 931 | else autoFitSendTextArea(); |
| 929 | }); | 932 | }); |
| 930 | | 933 | |
| 931 | restoreUserInput(); | 934 | restoreUserInput(); |