mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Fix: Inconsistent Textarea resizing in small windows
This commit is contained in:
		| @@ -699,20 +699,26 @@ const chatBlock = document.getElementById('chat'); | |||||||
| const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * this makes the chat input text area resize vertically to match the text size (limited by CSS at 50% window height) |  * Auto-resizes the send message textarea to fit its content, up to a maximum height defined by CSS. | ||||||
|  |  * This function preserves chat scroll position, resets the textarea height for accurate measurement, | ||||||
|  |  * calculates the required height, sets the new height, and then restores the chat scroll position. | ||||||
|  |  * Firefox-specific scrolling adjustments are included for smoother behavior. | ||||||
|  */ |  */ | ||||||
| function autoFitSendTextArea() { | function autoFitSendTextArea() { | ||||||
|     const originalScrollBottom = chatBlock.scrollHeight - (chatBlock.scrollTop + chatBlock.offsetHeight); |     const originalScrollTop = chatBlock.scrollTop; | ||||||
|     if (Math.ceil(sendTextArea.scrollHeight + 3) >= Math.floor(sendTextArea.offsetHeight)) { |     const originalScrollHeight = chatBlock.scrollHeight; | ||||||
|         const sendTextAreaMinHeight = '0px'; |  | ||||||
|         sendTextArea.style.height = sendTextAreaMinHeight; |     sendTextArea.style.height = '1px'; | ||||||
|     } |  | ||||||
|     const newHeight = sendTextArea.scrollHeight + 3; |     const newHeight = sendTextArea.scrollHeight;  | ||||||
|  |  | ||||||
|     sendTextArea.style.height = `${newHeight}px`; |     sendTextArea.style.height = `${newHeight}px`; | ||||||
|  |  | ||||||
|  |     // Restore chat scroll position (Firefox-specific adjustment for smoothness). | ||||||
|     if (!isFirefox) { |     if (!isFirefox) { | ||||||
|         const newScrollTop = Math.round(chatBlock.scrollHeight - (chatBlock.offsetHeight + originalScrollBottom)); |         chatBlock.scrollTop = originalScrollTop + (chatBlock.scrollHeight - originalScrollHeight); | ||||||
|         chatBlock.scrollTop = newScrollTop; |     } else { | ||||||
|  |        chatBlock.scrollTo({ top: chatBlock.scrollHeight, behavior: 'auto' });  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, debounce_timeout.short); | export const autoFitSendTextAreaDebounced = debounce(autoFitSendTextArea, debounce_timeout.short); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user