Skip to content

Commit 30ee20c

Browse files
author
Amrit Kashyap Borah
committed
fix: review comments
1 parent 2e534e8 commit 30ee20c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/Common/DraggableWrapper/DraggableWrapper.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import { useEffect, useRef, useState } from 'react'
1818
import Draggable, { ControlPosition } from 'react-draggable'
1919

20+
import { DEVTRON_BASE_MAIN_ID } from '@Shared/constants'
21+
2022
import { MAX_Z_INDEX } from '../Constants'
2123
import { useWindowSize } from '../Hooks'
2224
import { DraggablePositionVariant, DraggableWrapperProps } from './types'
@@ -25,7 +27,8 @@ import { DraggablePositionVariant, DraggableWrapperProps } from './types'
2527
* TODO: import it as lazy, after it is supported in common
2628
* 1. If using react select please use menuPlacement='auto'
2729
* 2. dragSelector will be used to identify the grabbable button that will grab the div to drag
28-
* 3. parentRef is the reference point from which we will derive the base top:0 ,left: 0 position
30+
* 3. The wrapper is positioned at the viewport's top-left (top: 0, left: 0) using fixed positioning; parentRef is an optional
31+
* reference that may be used for position calculations but is not the base origin for the coordinate system.
2932
*/
3033
const DraggableWrapper = ({
3134
children,
@@ -74,9 +77,7 @@ const DraggableWrapper = ({
7477
}
7578
// Add more cases for other variants if needed
7679
default: {
77-
// Since need node to be in center of screen so subtracting width/2 by left of parentRect it will start the node from center but want node's midpoint at center so subtracting node's width from it.
7880
const x = (windowSize.width - nodeRefWidth) / 2
79-
// subtracting top since windowSize already contains that
8081
const y = windowSize.height - nodeRefHeight - boundaryGap
8182

8283
return { x, y }
@@ -98,10 +99,10 @@ const DraggableWrapper = ({
9899
}}
99100
>
100101
<Draggable
101-
key={`${JSON.stringify(windowSize)} ${initialRenderDone}`}
102+
key={`${windowSize.height}-${windowSize.width}-${initialRenderDone}`}
102103
handle={dragSelector}
103104
defaultPosition={getDefaultPosition()}
104-
bounds="#devtron-base-main-identifier"
105+
bounds={`#${DEVTRON_BASE_MAIN_ID}`}
105106
nodeRef={nodeRef}
106107
>
107108
<div

0 commit comments

Comments
 (0)