فهرست منبع

Merge branch 'release' of github.com:DouyinFE/semi-design into release

pointhalo 3 سال پیش
والد
کامیت
a4bc3b0e4d
3فایلهای تغییر یافته به همراه15 افزوده شده و 1 حذف شده
  1. 4 0
      packages/semi-foundation/form/foundation.ts
  2. 1 0
      packages/semi-foundation/form/interface.ts
  3. 10 1
      packages/semi-ui/form/baseForm.tsx

+ 4 - 0
packages/semi-foundation/form/foundation.ts

@@ -75,6 +75,10 @@ export default class FormFoundation extends BaseFoundation<BaseFormAdapter> {
         this.scrollToField = this.scrollToField.bind(this);
     }
 
+    init() {
+        this._adapter.initFormId();
+    }
+
     getField(field: string): FieldStaff | undefined {
         const targetField = this.fields.get(field);
         return targetField;

+ 1 - 0
packages/semi-foundation/form/interface.ts

@@ -20,6 +20,7 @@ export interface BaseFormAdapter<P = Record<string, any>, S = Record<string, any
     getFormProps: (keys: undefined | string | Array<string>) => any;
     getAllErrorDOM: () => NodeList;
     getFieldDOM: (field: string) => Node;
+    initFormId: () => void;
 }
 
 export interface FormState<T extends Record<string, any> = any> {

+ 10 - 1
packages/semi-ui/form/baseForm.tsx

@@ -122,7 +122,7 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
     constructor(props: BaseFormProps) {
         super(props);
         this.state = {
-            formId: getUuidv4(),
+            formId: '',
         };
         warning(
             Boolean(props.component && props.render),
@@ -145,6 +145,10 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
         }
     }
 
+    componentDidMount() {
+        this.foundation.init();
+    }
+
     componentWillUnmount() {
         this.foundation.destroy();
         this.foundation = null;
@@ -173,6 +177,11 @@ class Form extends BaseComponent<BaseFormProps, BaseFormState> {
             notifyReset: () => {
                 this.props.onReset();
             },
+            initFormId: () => {
+                this.setState({
+                    formId: getUuidv4()
+                });
+            },
             getInitValues: () => this.props.initValues,
             getFormProps: (keys: undefined | string | Array<string>) => {
                 if (typeof keys === 'undefined') {