diff --git a/__tests__/renderers/Page.test.tsx b/__tests__/renderers/Page.test.tsx index 9e1a907eb..19e28899b 100644 --- a/__tests__/renderers/Page.test.tsx +++ b/__tests__/renderers/Page.test.tsx @@ -821,6 +821,7 @@ test('Renderer:Page handleAction actionType=drawer mergeData', async () => { ); fireEvent.click(getByText(/OpenDrawer/)); + await wait(600); expect(container).toMatchSnapshot(); fireEvent.click(getByText(/确认/)); @@ -1196,7 +1197,7 @@ test('Renderer:Page initApi reload by Drawer action', async () => { expect(container).toMatchSnapshot(); fireEvent.click(getByText(/OpenDialog/)); - await wait(400); + await wait(500); expect(container).toMatchSnapshot(); fireEvent.click(getByText(/确认/)); diff --git a/src/WithStore.tsx b/src/WithStore.tsx index e9a4d8fde..b4de67f88 100644 --- a/src/WithStore.tsx +++ b/src/WithStore.tsx @@ -218,9 +218,12 @@ export function HocStoreFactory(renderer: { // nextProps.data.__super !== props.data.__super) && } else if ( props.scope && + isObjectShallowModified(props.scope, prevProps.scope, false) && props.data === props.store!.data && (shouldSync === true || prevProps.data !== props.data) ) { + // 只有父级数据变动的时候才应该进来, + // 目前看来这个 case 很少有情况下能进来 store.initData( createObject(props.scope, { // ...nextProps.data, diff --git a/src/renderers/Dialog.tsx b/src/renderers/Dialog.tsx index dbd78c1f0..f78bcc523 100644 --- a/src/renderers/Dialog.tsx +++ b/src/renderers/Dialog.tsx @@ -605,8 +605,7 @@ export default class Dialog extends React.Component { shouldSyncSuperStore: (store: IServiceStore, props: any, prevProps: any) => (store.dialogOpen || props.show) && (props.show !== prevProps.show || - isObjectShallowModified(prevProps.data, props.data) || - isObjectShallowModified(prevProps.data.__super, props.data.__super)) + isObjectShallowModified(prevProps.data, props.data)) }) export class DialogRenderer extends Dialog { static contextType = ScopedContext; diff --git a/src/renderers/Drawer.tsx b/src/renderers/Drawer.tsx index 14ff03056..077237260 100644 --- a/src/renderers/Drawer.tsx +++ b/src/renderers/Drawer.tsx @@ -663,8 +663,7 @@ export default class Drawer extends React.Component { shouldSyncSuperStore: (store: IServiceStore, props: any, prevProps: any) => (store.drawerOpen || props.show) && (props.show !== prevProps.show || - isObjectShallowModified(prevProps.data, props.data) || - isObjectShallowModified(prevProps.data.__super, props.data.__super)) + isObjectShallowModified(prevProps.data, props.data)) }) export class DrawerRenderer extends Drawer { static contextType = ScopedContext; @@ -748,6 +747,7 @@ export class DrawerRenderer extends Drawer { action.actionType === 'confirm') && action.close !== false ) { + debugger; onConfirm && onConfirm(values, rawAction || action, ctx, targets); } else if (action.close) { action.close === true diff --git a/src/renderers/Page.tsx b/src/renderers/Page.tsx index 3eaca04fa..893f18fca 100644 --- a/src/renderers/Page.tsx +++ b/src/renderers/Page.tsx @@ -325,6 +325,8 @@ export default class Page extends React.Component { handleDrawerConfirm(values: object[], action: Action, ...args: Array) { const {store} = this.props; + console.log('here'); + if (action.mergeData && values.length === 1 && values[0]) { store.updateData(values[0]); }