Jelajahi Sumber

Update TableForm.js

Save, add or cancel operation, edit status is not updated.
解决保存、新增、取消操作,编辑状态不更新bug。
WeiYang Qiu 7 tahun lalu
induk
melakukan
285f7a5f5b
1 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 3 3
      src/routes/Forms/TableForm.js

+ 3 - 3
src/routes/Forms/TableForm.js

@@ -102,10 +102,10 @@ export default class TableForm extends PureComponent {
         });
         return;
       }
-      const { data } = this.state;
-      const { onChange } = this.props;
       delete target.isNew;
       this.toggleEditable(e, key);
+      const { data } = this.state;
+      const { onChange } = this.props;
       onChange(data);
       this.setState({
         loading: false,
@@ -121,9 +121,9 @@ export default class TableForm extends PureComponent {
     const target = this.getRowByKey(key, newData);
     if (this.cacheOriginData[key]) {
       Object.assign(target, this.cacheOriginData[key]);
-      target.editable = false;
       delete this.cacheOriginData[key];
     }
+    target.editable = false;
     this.setState({ data: newData });
     this.clickedCancel = false;
   }