Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

Fix scrolling in component sidebar for textarea

ali-inkco80853542f32d
diff --git a/packages/app/src/builder-ui/ui/dialogs.ts b/packages/app/src/builder-ui/ui/dialogs.ts
index 037cb0fc..509b4f30 100644
--- a/packages/app/src/builder-ui/ui/dialogs.ts
+++ b/packages/app/src/builder-ui/ui/dialogs.ts
@@ -1172,6 +1172,25 @@ export function sidebarEditValues({
}
}, 500);
+ /**
+ * Helper function to update textarea scrollbar state
+ * @param textarea - The textarea element to update
+ */
+ const updateTextareaScrollbar = (textarea: HTMLTextAreaElement): void => {
+ // Remove MetroUI class that interferes
+ textarea.parentElement?.classList.remove('no-scroll-vertical');
+
+ // Show/hide scrollbar only when content exceeds available space
+ // Account for borders: offsetHeight includes borders, clientHeight doesn't
+ const borderHeight = textarea.offsetHeight - textarea.clientHeight;
+ const maxContentHeight = 176 - borderHeight;
+ const needsScroll = textarea.scrollHeight > maxContentHeight;
+
+ // Use CSS classes instead of inline styles to override MetroUI
+ textarea.classList.remove('overflow-y-auto', 'overflow-y-hidden');
+ textarea.classList.add(needsScroll ? 'overflow-y-auto' : 'overflow-y-hidden');
+ };
+
// Listen for immediate input changes (text inputs, textareas)
_form.addEventListener(
'input',
@@ -1184,18 +1203,7 @@ export function sidebarEditValues({
if (target.matches('textarea')) {
const textarea = target as HTMLTextAreaElement;
setTimeout(() => {
- // Remove MetroUI class that interferes
- textarea.parentElement?.classList.remove('no-scroll-vertical');
-
- // Show/hide scrollbar only when content exceeds available space
- // Account for borders: offsetHeight includes borders, clientHeight doesn't
- const borderHeight = textarea.offsetHeight - textarea.clientHeight;
- const maxContentHeight = 176 - borderHeight;
- const needsScroll = textarea.scrollHeight > maxContentHeight;
-
- // Use CSS classes instead of inline styles to override MetroUI
- textarea.classList.remove('overflow-y-auto', 'overflow-y-hidden');
- textarea.classList.add(needsScroll ? 'overflow-y-auto' : 'overflow-y-hidden');
+ updateTextareaScrollbar(textarea);
}, 0);
}
}
@@ -1255,6 +1263,15 @@ export function sidebarEditValues({
_form._init();
forms[tab] = { form: _form, fields: formFields };
+
+ // Initialize scrollbar state for all textareas (including prefilled ones)
+ // Use setTimeout to ensure the DOM is fully rendered and textarea dimensions are calculated
+ setTimeout(() => {
+ const textareas = _form.querySelectorAll('textarea') as NodeListOf<HTMLTextAreaElement>;
+ textareas.forEach((textarea: HTMLTextAreaElement) => {
+ updateTextareaScrollbar(textarea);
+ });
+ }, 0);
} else {
containers[tab].innerHTML = entriesObject[tab];
containers[tab].classList.add('mx-4');