mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:58:05 +08:00
修复弹窗打开卡主问题 (#2146)
This commit is contained in:
parent
dcb290fdd4
commit
eee47f5143
@ -63,16 +63,16 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
|
||||
this.resolveRenderer(this.props);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: SchemaRendererProps) {
|
||||
componentDidUpdate(prevProps: SchemaRendererProps) {
|
||||
const props = this.props;
|
||||
|
||||
if (
|
||||
prevProps.schema &&
|
||||
props.schema &&
|
||||
nextProps.schema &&
|
||||
(props.schema.type !== nextProps.schema.type ||
|
||||
props.schema.$$id !== nextProps.schema.$$id)
|
||||
(prevProps.schema.type !== props.schema.type ||
|
||||
prevProps.schema.$$id !== props.schema.$$id)
|
||||
) {
|
||||
this.resolveRenderer(nextProps);
|
||||
this.resolveRenderer(props);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,13 +183,14 @@ export function HocStoreFactory(renderer: {
|
||||
props.data.__super
|
||||
) {
|
||||
// 这个用法很少,当 data.__super 值发生变化时,更新 store.data
|
||||
(!prevProps.data ||
|
||||
if (
|
||||
!prevProps.data ||
|
||||
isObjectShallowModified(
|
||||
props.data.__super,
|
||||
prevProps.data.__super,
|
||||
false
|
||||
)) &&
|
||||
// nextProps.data.__super !== props.data.__super) &&
|
||||
)
|
||||
) {
|
||||
store.initData(
|
||||
createObject(props.data.__super, {
|
||||
...props.data,
|
||||
@ -199,6 +200,8 @@ export function HocStoreFactory(renderer: {
|
||||
store.storeType === 'FormStore' &&
|
||||
prevProps.store?.storeType === 'CRUDStore'
|
||||
);
|
||||
}
|
||||
// nextProps.data.__super !== props.data.__super) &&
|
||||
} else if (
|
||||
props.scope &&
|
||||
props.data === props.store!.data &&
|
||||
|
@ -5,7 +5,12 @@ import {SchemaNode, Schema, Action} from '../types';
|
||||
import {filter} from '../utils/tpl';
|
||||
import Modal from '../components/Modal';
|
||||
import findLast from 'lodash/findLast';
|
||||
import {guid, isVisible, autobind} from '../utils/helper';
|
||||
import {
|
||||
guid,
|
||||
isVisible,
|
||||
autobind,
|
||||
isObjectShallowModified
|
||||
} from '../utils/helper';
|
||||
import {reaction} from 'mobx';
|
||||
import {Icon} from '../components/icons';
|
||||
import {ModalStore, IModalStore} from '../store/modal';
|
||||
@ -591,8 +596,9 @@ export default class Dialog extends React.Component<DialogProps> {
|
||||
storeType: ModalStore.name,
|
||||
storeExtendsData: false,
|
||||
isolateScope: true,
|
||||
shouldSyncSuperStore: (store: IServiceStore, props: any) =>
|
||||
store.dialogOpen || props.show
|
||||
shouldSyncSuperStore: (store: IServiceStore, props: any, prevProps: any) =>
|
||||
(store.dialogOpen || props.show) &&
|
||||
isObjectShallowModified(prevProps.data, props.data)
|
||||
})
|
||||
export class DialogRenderer extends Dialog {
|
||||
static contextType = ScopedContext;
|
||||
|
@ -4,7 +4,12 @@ import {Renderer, RendererProps} from '../factory';
|
||||
import {SchemaNode, Schema, Action} from '../types';
|
||||
import {default as DrawerContainer} from '../components/Drawer';
|
||||
import findLast from 'lodash/findLast';
|
||||
import {guid, isVisible, autobind} from '../utils/helper';
|
||||
import {
|
||||
guid,
|
||||
isVisible,
|
||||
autobind,
|
||||
isObjectShallowModified
|
||||
} from '../utils/helper';
|
||||
import {reaction} from 'mobx';
|
||||
import {findDOMNode} from 'react-dom';
|
||||
import {IModalStore, ModalStore} from '../store/modal';
|
||||
@ -649,8 +654,9 @@ export default class Drawer extends React.Component<DrawerProps> {
|
||||
storeType: ModalStore.name,
|
||||
storeExtendsData: false,
|
||||
isolateScope: true,
|
||||
shouldSyncSuperStore: (store: IServiceStore, props: any) =>
|
||||
store.drawerOpen || props.show
|
||||
shouldSyncSuperStore: (store: IServiceStore, props: any, prevProps: any) =>
|
||||
(store.drawerOpen || props.show) &&
|
||||
isObjectShallowModified(prevProps.data, props.data)
|
||||
})
|
||||
export class DrawerRenderer extends Drawer {
|
||||
static contextType = ScopedContext;
|
||||
|
@ -17,7 +17,8 @@ import {
|
||||
cloneObject,
|
||||
SkipOperation,
|
||||
isEmpty,
|
||||
getVariable
|
||||
getVariable,
|
||||
isObjectShallowModified
|
||||
} from '../../utils/helper';
|
||||
import debouce from 'lodash/debounce';
|
||||
import flatten from 'lodash/flatten';
|
||||
@ -1587,12 +1588,14 @@ export default class Form extends React.Component<FormProps, object> {
|
||||
type: 'form',
|
||||
storeType: FormStore.name,
|
||||
isolateScope: true,
|
||||
shouldSyncSuperStore: (store, nextProps) => {
|
||||
shouldSyncSuperStore: (store, props, prevProps) => {
|
||||
// 如果是 QuickEdit,让 store 同步 __super 数据。
|
||||
if (
|
||||
nextProps.canAccessSuperData &&
|
||||
nextProps.quickEditFormRef &&
|
||||
nextProps.onQuickChange
|
||||
props.canAccessSuperData &&
|
||||
props.quickEditFormRef &&
|
||||
props.onQuickChange &&
|
||||
(isObjectShallowModified(prevProps.data, props.data) ||
|
||||
isObjectShallowModified(prevProps.data.__super, props.data.__super))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user