Skip to content

Commit 2a82955

Browse files
committed
[Fix]: render the drawer inside the preivew/app canvas
1 parent a7a9a1b commit 2a82955

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

client/packages/lowcoder/src/comps/comps/layout/mobileTabLayout.tsx

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import { manualOptionsControl } from "comps/controls/optionsControl";
55
import { BoolCodeControl, StringControl, jsonControl, NumberControl } from "comps/controls/codeControl";
66
import { IconControl } from "comps/controls/iconControl";
77
import styled from "styled-components";
8-
import React, { Suspense, useContext, useEffect, useMemo, useState } from "react";
8+
import React, { Suspense, useContext, useEffect, useMemo, useState, useCallback } from "react";
99
import { registerLayoutMap } from "comps/comps/uiComp";
1010
import { AppSelectComp } from "comps/comps/layout/appSelectComp";
1111
import { NameAndExposingInfo } from "comps/utils/exposingTypes";
1212
import { ConstructorToComp, ConstructorToDataType } from "lowcoder-core";
1313
import { CanvasContainer } from "comps/comps/gridLayoutComp/canvasView";
1414
import { CanvasContainerID } from "constants/domLocators";
15+
import { PreviewContainerID } from "constants/domLocators";
1516
import { EditorContainer, EmptyContent } from "pages/common/styledComponent";
1617
import { Layers } from "constants/Layers";
1718
import { ExternalEditorContext } from "util/context/ExternalEditorContext";
@@ -30,6 +31,7 @@ import { ThemeContext } from "@lowcoder-ee/comps/utils/themeContext";
3031
import { AlignCenter } from "lowcoder-design";
3132
import { AlignLeft } from "lowcoder-design";
3233
import { AlignRight } from "lowcoder-design";
34+
import { Drawer } from "lowcoder-design";
3335
import { LayoutActionComp } from "./layoutActionComp";
3436
import { defaultTheme } from "@lowcoder-ee/constants/themeConstants";
3537
import { clickEvent, eventHandlerControl } from "@lowcoder-ee/comps/controls/eventHandlerControl";
@@ -43,7 +45,6 @@ const TabBarItem = React.lazy(() =>
4345
default: module.TabBarItem,
4446
}))
4547
);
46-
const Popup = React.lazy(() => import("antd-mobile/es/components/popup"));
4748
const EventOptions = [clickEvent] as const;
4849

4950
const AppViewContainer = styled.div`
@@ -620,6 +621,13 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
620621
const bgColor = (useContext(ThemeContext)?.theme || defaultTheme).canvas;
621622
const onEvent = comp.children.onEvent.getView();
622623

624+
const getContainer = useCallback(() =>
625+
document.querySelector(`#${PreviewContainerID}`) ||
626+
document.querySelector(`#${CanvasContainerID}`) ||
627+
document.body,
628+
[]
629+
);
630+
623631
useEffect(() => {
624632
comp.children.jsonTabs.dispatchChangeValueAction({
625633
manual: jsonItems as unknown as Array<ConstructorToDataType<typeof TabOptionComp>>
@@ -749,22 +757,27 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
749757
</HamburgerButton>
750758
);
751759

752-
const drawerBodyStyle = useMemo(() => {
753-
if (drawerPlacement === 'left' || drawerPlacement === 'right') {
754-
return { width: drawerWidth } as React.CSSProperties;
755-
}
756-
return { height: drawerHeight } as React.CSSProperties;
757-
}, [drawerPlacement, drawerHeight, drawerWidth]);
758-
759760
const drawerView = (
760761
<Suspense fallback={<Skeleton />}>
761-
<Popup
762-
visible={drawerVisible}
763-
onMaskClick={() => setDrawerVisible(false)}
762+
<Drawer
763+
open={drawerVisible}
764764
onClose={() => setDrawerVisible(false)}
765-
position={drawerPlacement as any}
765+
placement={drawerPlacement as any}
766766
mask={shadowOverlay}
767-
bodyStyle={drawerBodyStyle}
767+
maskClosable={true}
768+
closable={false}
769+
styles={{ body: { padding: 0 } } as any}
770+
getContainer={getContainer}
771+
width={
772+
(drawerPlacement === 'left' || drawerPlacement === 'right')
773+
? (drawerWidth as any)
774+
: undefined
775+
}
776+
height={
777+
(drawerPlacement === 'top' || drawerPlacement === 'bottom')
778+
? (drawerHeight as any)
779+
: undefined
780+
}
768781
>
769782
<DrawerContent
770783
$background={drawerContainerStyle?.background || '#FFFFFF'}
@@ -808,7 +821,7 @@ MobileTabLayoutTmp = withViewFn(MobileTabLayoutTmp, (comp) => {
808821
))}
809822
</DrawerList>
810823
</DrawerContent>
811-
</Popup>
824+
</Drawer>
812825
</Suspense>
813826
);
814827

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const CanvasContainerID = "__canvas_container__";
22
export const CodeEditorTooltipContainerID = "__code_editor_tooltip__";
3+
export const PreviewContainerID = "__preview_container__";

client/packages/lowcoder/src/pages/editor/editorView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { isEqual, noop } from "lodash";
6464
import { AppSettingContext, AppSettingType } from "@lowcoder-ee/comps/utils/appSettingContext";
6565
import { getBrandingSetting } from "@lowcoder-ee/redux/selectors/enterpriseSelectors";
6666
import Flex from "antd/es/flex";
67+
import { PreviewContainerID } from "constants/domLocators";
6768
// import { BottomSkeleton } from "./bottom/BottomContent";
6869

6970
const Header = lazy(
@@ -534,10 +535,12 @@ function EditorView(props: EditorViewProps) {
534535
deviceType={editorState.deviceType}
535536
deviceOrientation={editorState.deviceOrientation}
536537
>
537-
{uiComp.getView()}
538+
<div id={PreviewContainerID}>
539+
{uiComp.getView()}
540+
</div>
538541
</DeviceWrapper>
539542
) : (
540-
<div>
543+
<div id={PreviewContainerID}>
541544
{uiComp.getView()}
542545
</div>
543546
)

0 commit comments

Comments
 (0)