Merge pull request #2219 from 2betop/drawer

drawer 成员加载时机优化
This commit is contained in:
RickCole 2021-07-05 16:20:32 +08:00 committed by GitHub
commit d36d04116b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -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(/确认/));

View File

@ -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,

View File

@ -605,8 +605,7 @@ export default class Dialog extends React.Component<DialogProps> {
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;

View File

@ -599,9 +599,15 @@ export default class Drawer extends React.Component<DrawerProps> {
: null}
</div>
<div className={cx('Drawer-body', bodyClassName)}>
{body ? this.renderBody(body, 'body') : null}
</div>
{!store.entered ? (
<div className={cx('Drawer-body', bodyClassName)}>
<Spinner overlay show size="lg" />
</div>
) : body ? (
<div className={cx('Drawer-body', bodyClassName)}>
{this.renderBody(body, 'body')}
</div>
) : null}
{this.renderFooter()}
@ -657,8 +663,7 @@ export default class Drawer extends React.Component<DrawerProps> {
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;