Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 81ef532

Browse files
authored
UX: Only scroll when we surpass max input height (#1288)
1 parent cd0cfc0 commit 81ef532

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

assets/javascripts/discourse/controllers/discourse-ai-bot-conversations.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,15 @@ export default class DiscourseAiBotConversations extends Controller {
4848
_autoExpandTextarea() {
4949
this.textarea.style.height = "auto";
5050
this.textarea.style.height = this.textarea.scrollHeight + "px";
51+
52+
// Get the max-height value from CSS (30vh)
53+
const maxHeight = parseInt(getComputedStyle(this.textarea).maxHeight, 10);
54+
55+
// Only enable scrolling if content exceeds max-height
56+
if (this.textarea.scrollHeight > maxHeight) {
57+
this.textarea.style.overflowY = "auto";
58+
} else {
59+
this.textarea.style.overflowY = "hidden";
60+
}
5161
}
5262
}

assets/stylesheets/modules/ai-bot-conversations/common.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ body.has-ai-conversations-sidebar {
248248
resize: none;
249249
border-radius: var(--d-button-border-radius);
250250
max-height: 30vh;
251-
overflow: hidden;
251+
overflow-y: hidden;
252252

253253
&:focus {
254254
outline: none;

0 commit comments

Comments
 (0)