Skip to content

Commit 0d2d8e4

Browse files
committed
make drawer placement control consistent
1 parent 795c181 commit 0d2d8e4

File tree

1 file changed

+11
-8
lines changed
  • client/packages/lowcoder/src/comps/comps/navComp

1 file changed

+11
-8
lines changed

client/packages/lowcoder/src/comps/comps/navComp/navComp.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Section, sectionNames } from "lowcoder-design";
55
import styled from "styled-components";
66
import { clickEvent, eventHandlerControl } from "comps/controls/eventHandlerControl";
77
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
8-
import { dropdownControl } from "comps/controls/dropdownControl";
8+
import { dropdownControl, PositionControl } from "comps/controls/dropdownControl";
99
import { alignWithJustifyControl } from "comps/controls/alignControl";
1010
import { navListComp } from "./navItemComp";
1111
import { menuPropertyView } from "./components/MenuItemList";
@@ -29,10 +29,11 @@ import {
2929
import { hiddenPropertyView, showDataLoadingIndicatorsPropertyView } from "comps/utils/propertyUtils";
3030
import { trans } from "i18n";
3131

32-
import { useContext, useState } from "react";
32+
import { useContext, useState, useCallback } from "react";
3333
import { EditorContext } from "comps/editorState";
3434
import { createNavItemsControl } from "./components/NavItemsControl";
3535
import { Layers } from "constants/Layers";
36+
import { CanvasContainerID } from "constants/domLocators";
3637

3738
type IProps = {
3839
$justify: boolean;
@@ -234,7 +235,7 @@ function renderLayoutSection(children: any) {
234235
...common,
235236
children.hamburgerPosition.propertyView({ label: "Hamburger Position" }),
236237
children.hamburgerSize.propertyView({ label: "Hamburger Size" }),
237-
children.drawerPlacement.propertyView({ label: "Drawer Placement", radioButton: true }),
238+
children.placement.propertyView({ label: trans("drawer.placement"), radioButton: true }),
238239
children.shadowOverlay.propertyView({ label: "Shadow Overlay" }),
239240
];
240241
const bar = [
@@ -311,10 +312,7 @@ const childrenMap = {
311312
{ label: "Bottom Left", value: "bottom-left" },
312313
], "top-right"),
313314
hamburgerSize: withDefault(StringControl, "56px"),
314-
drawerPlacement: dropdownControl([
315-
{ label: "Left", value: "left" },
316-
{ label: "Right", value: "right" },
317-
], "right"),
315+
placement: PositionControl,
318316
shadowOverlay: withDefault(BoolCodeControl, true),
319317
horizontalAlignment: alignWithJustifyControl(),
320318
style: migrateOldData(styleControl(NavigationStyle, 'style'), fixOldStyleData),
@@ -336,6 +334,10 @@ const childrenMap = {
336334

337335
const NavCompBase = new UICompBuilder(childrenMap, (props) => {
338336
const [drawerVisible, setDrawerVisible] = useState(false);
337+
const getContainer = useCallback(() =>
338+
document.querySelector(`#${CanvasContainerID}`) || document.body,
339+
[]
340+
);
339341
const data = props.items;
340342
const items = (
341343
<>
@@ -471,11 +473,12 @@ const NavCompBase = new UICompBuilder(childrenMap, (props) => {
471473
<MenuOutlined />
472474
</FloatingHamburgerButton>
473475
<Drawer
474-
placement={(props.drawerPlacement as any) || "right"}
476+
placement={props.placement || "right"}
475477
closable={true}
476478
onClose={() => setDrawerVisible(false)}
477479
open={drawerVisible}
478480
mask={props.shadowOverlay}
481+
getContainer={getContainer}
479482
styles={{ body: { padding: "8px", background: props.drawerContainerStyle?.background } }}
480483
destroyOnClose
481484
>

0 commit comments

Comments
 (0)