Skip to content

Commit e2a39ef

Browse files
upgrade react-draggable, added missing nodeRef
1 parent 80a2d08 commit e2a39ef

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

client/packages/lowcoder-design/src/components/CustomModal.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ButtonProps } from "antd/es/button";
22
import { default as AntdModal, ModalFuncProps, ModalProps as AntdModalProps } from "antd/es/modal";
33
import { ReactComponent as PackUpIcon } from "icons/v1/icon-Pack-up.svg";
4-
import React, { ReactNode, useState } from "react";
4+
import React, { ReactNode, useRef, useState } from "react";
55
import styled from "styled-components";
66
import { TacoButtonType, TacoButton } from "components/button";
77
import Draggable from "react-draggable";
@@ -221,9 +221,12 @@ const DEFAULT_PROPS = {
221221
} as const;
222222

223223
function CustomModalRender(props: Omit<CustomModalProps & ModalFuncProps, "width"> & { width?: string | number }) {
224+
const draggableRef = useRef<HTMLDivElement>(null);
225+
224226
return (
225-
<Draggable handle=".handle" disabled={!props.draggable}>
226-
<ModalWrapper
227+
<Draggable handle=".handle" disabled={!props.draggable} nodeRef={draggableRef}>
228+
<ModalWrapper
229+
ref={draggableRef}
227230
$width={props.width}
228231
$customStyles={props?.customStyles}
229232
>

client/packages/lowcoder-design/src/components/iconSelect/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class Icon {
152152
else
153153
return (
154154
<FontAwesomeIcon
155+
className=""
155156
icon={this.def}
156157
style={{ width: "1em", height: "1em"}}
157158
/>
@@ -256,6 +257,7 @@ const IconPopup = (props: {
256257
searchKeywords?: Record<string, string>;
257258
IconType?: "OnlyAntd" | "All" | "default" | undefined;
258259
}) => {
260+
const draggableRef = useRef<HTMLDivElement>(null);
259261
const [searchText, setSearchText] = useState("");
260262
const [allIcons, setAllIcons] = useState<Record<string, Icon>>({});
261263
const searchResults = useMemo(
@@ -289,6 +291,7 @@ const IconPopup = (props: {
289291
title={icon.title + ", Key: " + key}
290292
placement="bottom"
291293
align={{ offset: [0, -7, 0, 0] }}
294+
getPopupContainer={(node: any) => node.parentNode}
292295
destroyTooltipOnHide
293296
>
294297
<IconItemContainer
@@ -311,8 +314,8 @@ const IconPopup = (props: {
311314
[searchResults, allIcons, onChangeIcon]
312315
);
313316
return (
314-
<Draggable handle=".dragHandle">
315-
<PopupContainer>
317+
<Draggable handle=".dragHandle" nodeRef={draggableRef}>
318+
<PopupContainer ref={draggableRef}>
316319
<TitleDiv className="dragHandle">
317320
<TitleText>{trans("iconSelect.title")}</TitleText>
318321
<StyledCloseIcon onClick={props.onClose} />

client/packages/lowcoder-design/src/components/shapeSelect/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ const IconPopup = (props: {
328328
searchKeywords?: Record<string, string>;
329329
IconType?: "OnlyAntd" | "All" | "default" | undefined;
330330
}) => {
331+
const draggableRef = useRef<HTMLDivElement>(null);
331332
const [allIcons, setAllIcons] = useState<Record<string, Icon>>({});
332333
const onChangeRef = useRef(props.onChange);
333334
onChangeRef.current = props.onChange;
@@ -374,8 +375,8 @@ const IconPopup = (props: {
374375
// [searchResults, allIcons, onChangeIcon]
375376
// );
376377
return (
377-
<Draggable handle=".dragHandle">
378-
<PopupContainer>
378+
<Draggable handle=".dragHandle" nodeRef={draggableRef}>
379+
<PopupContainer ref={draggableRef}>
379380
<TitleDiv className="dragHandle">
380381
<TitleText>{trans("shapeSelect.title")}</TitleText>
381382
<StyledCloseIcon onClick={props.onClose} />

client/packages/lowcoder/src/components/resultPanel/BottomResultPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const BottomResultPanel = (props: BottomResultPanelProps) => {
5555

5656
return (
5757
<Draggable
58+
nodeRef={draggableRef}
5859
disabled={unDraggable}
5960
bounds={bounds}
6061
enableUserSelectHack={false}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export const CodeEditorPanel = (props: {
164164
getPopupContainer={(node: any) => node.parentNode.parentNode}
165165
popup={() => (
166166
<Draggable
167+
nodeRef={draggableRef}
167168
positionOffset={{ x: "-50%", y: "-50%" }}
168169
disabled={unDraggable}
169170
bounds={bounds}

0 commit comments

Comments
 (0)