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.

use doNotValidateOnLoad to offset validation for component field on creations

ali-inkco03bd84ffcf1d
diff --git a/packages/app/src/builder-ui/components/APIEndpoint.class.ts b/packages/app/src/builder-ui/components/APIEndpoint.class.ts
index 0f9abc99..f87da477 100644
--- a/packages/app/src/builder-ui/components/APIEndpoint.class.ts
+++ b/packages/app/src/builder-ui/components/APIEndpoint.class.ts
@@ -53,6 +53,7 @@ export class APIEndpoint extends Component {
endpoint: {
type: 'input',
label: 'Skill Name',
+ doNotValidateOnLoad: true,
value: '',
validate: `required maxlength=50 custom=isValidEndpoint`,
validateMessage: `Provide a valid endpoint that only contains 'a-z', 'A-Z', '0-9', '-', '_' , without leading or trailing spaces. Length should be less than 50 characters.`,
diff --git a/packages/app/src/builder-ui/ui/form/createFormField.ts b/packages/app/src/builder-ui/ui/form/createFormField.ts
index 89931601..c57e837b 100644
--- a/packages/app/src/builder-ui/ui/form/createFormField.ts
+++ b/packages/app/src/builder-ui/ui/form/createFormField.ts
@@ -367,7 +367,25 @@ export default function createFormField(entry, displayType = 'block', entryIndex
//formElement.setAttribute('data-prepend', entry.label || entry.name); //
if (entry.readonly) formElement.setAttribute('readonly', '');
- if (entry.validate) formElement.setAttribute('data-validate', entry.validate);
+ if (entry.validate) {
+ if (entry.doNotValidateOnLoad) {
+ // Store validation rules but don't apply them yet
+ formElement.setAttribute('data-validate-rules', entry.validate);
+ // Add validation after first user interaction
+ const enableValidation = () => {
+ formElement.setAttribute('data-validate', entry.validate);
+ formElement.removeAttribute('data-validate-rules');
+ formElement.removeEventListener('focus', enableValidation);
+ formElement.removeEventListener('input', enableValidation);
+ formElement.removeEventListener('change', enableValidation);
+ };
+ formElement.addEventListener('focus', enableValidation, { once: true });
+ formElement.addEventListener('input', enableValidation, { once: true });
+ formElement.addEventListener('change', enableValidation, { once: true });
+ } else {
+ formElement.setAttribute('data-validate', entry.validate);
+ }
+ }
/*
* "entry.smythValidate" allows custom validation using asynchronous functions. (Metro UI does not support asynchronous function.)
diff --git a/packages/app/src/builder-ui/utils/form.utils.ts b/packages/app/src/builder-ui/utils/form.utils.ts
index 9b5836ed..da584ef2 100644
--- a/packages/app/src/builder-ui/utils/form.utils.ts
+++ b/packages/app/src/builder-ui/utils/form.utils.ts
@@ -1,4 +1,3 @@
-import { delay } from './general.utils';
export const focusField = (elm: HTMLInputElement) => {
if (!elm) return;
diff --git a/packages/app/static/css/smyth-metro-override.css b/packages/app/static/css/smyth-metro-override.css
index 35542bbd..11d02a0e 100644
--- a/packages/app/static/css/smyth-metro-override.css
+++ b/packages/app/static/css/smyth-metro-override.css
@@ -52,6 +52,11 @@
padding: 0 !important;
}
+.input.invalid:focus,
+.input.invalid.focused {
+ -webkit-box-shadow: none !important;
+ box-shadow: none !important;
+}
/* Remove checkerboard pattern from external Coloris library */
/* High specificity overrides for CDN Coloris CSS */