UX: Only scroll when we surpass max input height (#1288)

This commit is contained in:
Isaac Janzen 2025-04-25 13:20:34 -05:00 committed by GitHub
parent cd0cfc0bfc
commit 81ef532268
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -48,5 +48,15 @@ export default class DiscourseAiBotConversations extends Controller {
_autoExpandTextarea() {
this.textarea.style.height = "auto";
this.textarea.style.height = this.textarea.scrollHeight + "px";
// Get the max-height value from CSS (30vh)
const maxHeight = parseInt(getComputedStyle(this.textarea).maxHeight, 10);
// Only enable scrolling if content exceeds max-height
if (this.textarea.scrollHeight > maxHeight) {
this.textarea.style.overflowY = "auto";
} else {
this.textarea.style.overflowY = "hidden";
}
}
}

View File

@ -248,7 +248,7 @@ body.has-ai-conversations-sidebar {
resize: none;
border-radius: var(--d-button-border-radius);
max-height: 30vh;
overflow: hidden;
overflow-y: hidden;
&:focus {
outline: none;