Ivan Galakhov 4 лет назад
Родитель
Сommit
c5476b9073

+ 1 - 1
dashboard/src/components/porter-form/PorterFormContextProvider.tsx

@@ -310,7 +310,7 @@ export const PorterFormContextProvider: React.FC<Props> = (props) => {
             return;
           // fields that have defaults can't be required since we can always
           // compute their value
-          if (field.required && !field.settings?.default) {
+          if (field.required && !field.settings?.default && !field.value) {
             requiredIds.push(field.id);
           }
           if (!mapping[field.variable]) {

+ 4 - 6
dashboard/src/components/porter-form/field-components/Input.tsx

@@ -22,14 +22,12 @@ const Input: React.FC<InputField> = ({
   const clipOffUnit = (x: string) => {
     let unit = settings?.unit;
     if (typeof x === "string" && unit) {
-      return unit === x.slice(x.length - unit.length, x.length) ? (
-        x.slice(0, x.length - unit.length)
-      ) : (
-        x
-      );
+      return unit === x.slice(x.length - unit.length, x.length)
+        ? x.slice(0, x.length - unit.length)
+        : x;
     }
     return x;
-  }
+  };
 
   const {
     state,