fix: Form组件配置页面跳转事件可能会导致持久化数据无法清除问题 (#8354)

This commit is contained in:
RUNZE LU 2023-10-12 19:06:27 +08:00 committed by GitHub
parent ef2cb9b6b6
commit 3dd28ad243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1154,6 +1154,8 @@ export default class Form extends React.Component<FormProps, object> {
if (target) {
this.submitToTarget(filterTarget(target, values), values);
/** 可能配置页面跳转事件页面路由变化导致persistKey不一致无法清除持久化数据所以提交成功事件之前先清理一下 */
clearPersistDataAfterSubmit && store.clearLocalPersistData();
dispatchEvent('submitSucc', createObject(this.props.data, values));
} else if (action.actionType === 'reload') {
action.target &&
@ -1185,6 +1187,7 @@ export default class Form extends React.Component<FormProps, object> {
? filter(saveFailed, store.data)
: undefined,
onSuccess: async (result: Payload) => {
clearPersistDataAfterSubmit && store.clearLocalPersistData();
// result为提交接口返回的内容
const dispatcher = await dispatchEvent(
'submitSucc',
@ -1245,6 +1248,7 @@ export default class Form extends React.Component<FormProps, object> {
});
});
} else {
clearPersistDataAfterSubmit && store.clearLocalPersistData();
// type为submit但是没有配api以及target时只派发事件
dispatchEvent('submitSucc', createObject(this.props.data, values));
}