Skip to content

Commit 2d2a077

Browse files
author
Amrit Kashyap Borah
committed
chore: rm file from eslintignore
1 parent 011e8a7 commit 2d2a077

3 files changed

Lines changed: 13 additions & 20 deletions

File tree

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ src/Common/DebouncedSearch/__tests__/DebouncedSearch.test.tsx
2323
src/Common/DevtronProgressing/DevtronProgressing.tsx
2424
src/Common/Dialogs/DialogForm.tsx
2525
src/Common/DraggableWrapper/DraggableButton.tsx
26-
src/Common/DraggableWrapper/DraggableWrapper.tsx
2726
src/Common/Drawer/Drawer.tsx
2827
src/Common/Grid/Grid.tsx
2928
src/Common/Helper.tsx

src/Common/DraggableWrapper/DraggableWrapper.tsx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,34 @@
1515
*/
1616

1717
import { useEffect, useRef, useState } from 'react'
18-
import Draggable, { ControlPosition, DraggableData } from 'react-draggable'
19-
import { DraggableWrapperProps, DraggablePositionVariant } from './types'
20-
import { useWindowSize } from '../Hooks'
18+
import Draggable, { ControlPosition } from 'react-draggable'
19+
2120
import { MAX_Z_INDEX } from '../Constants'
21+
import { useWindowSize } from '../Hooks'
22+
import { DraggablePositionVariant, DraggableWrapperProps } from './types'
2223

2324
/**
2425
* TODO: import it as lazy, after it is supported in common
2526
* 1. If using react select please use menuPlacement='auto'
2627
* 2. dragSelector will be used to identify the grabbable button that will grab the div to drag
2728
* 3. parentRef is the reference point from which we will derive the base top:0 ,left: 0 position
2829
*/
29-
export default function DraggableWrapper({
30+
const DraggableWrapper = ({
3031
children,
3132
zIndex = MAX_Z_INDEX,
3233
positionVariant,
3334
dragSelector,
3435
parentRef,
3536
boundaryGap = 16,
3637
childDivProps = {},
37-
layoutFixDelta = 0,
38-
}: DraggableWrapperProps) {
38+
}: DraggableWrapperProps) => {
3939
const windowSize = useWindowSize()
4040
const nodeRef = useRef<HTMLDivElement>(null)
41-
41+
4242
// letting the dom render the element without displaying it so that we know it's dimensions
4343
const [initialRenderDone, setInitialRenderDone] = useState(false)
4444

45-
const getDefaultPosition = (positionVariant: DraggablePositionVariant): ControlPosition => {
45+
const getDefaultPosition = (): ControlPosition => {
4646
// if this return x: 0, y: 0 then it will be top left corner of parentDiv
4747
const parentRect =
4848
parentRef?.current?.getBoundingClientRect() ??
@@ -60,10 +60,6 @@ export default function DraggableWrapper({
6060
case DraggablePositionVariant.PARENT_BOTTOM_CENTER: {
6161
// center div to middle of the parent rect and then add the left offset of the parent rect
6262
const x = (parentRect.width - nodeRefWidth) / 2 + parentRect.left
63-
// TODO (v3): Temp fix. Revisit
64-
const parentRectTop = parentRect.top > 0 ? parentRect.top : layoutFixDelta
65-
// currently at parentRect.y now parent height can be greater than windowSize.height so taking min
66-
// subtracting parentRect.top since window height already contains that
6763
if (parentRect.height > windowSize.height) {
6864
return { x, y: windowSize.height - boundaryGap - nodeRefHeight }
6965
}
@@ -104,9 +100,10 @@ export default function DraggableWrapper({
104100
<Draggable
105101
key={`${JSON.stringify(windowSize)} ${initialRenderDone}`}
106102
handle={dragSelector}
107-
defaultPosition={getDefaultPosition(positionVariant)}
103+
defaultPosition={getDefaultPosition()}
108104
bounds="#devtron-base-main-identifier"
109-
nodeRef={nodeRef}>
105+
nodeRef={nodeRef}
106+
>
110107
<div
111108
ref={nodeRef}
112109
{...childDivProps}
@@ -121,3 +118,5 @@ export default function DraggableWrapper({
121118
</div>
122119
)
123120
}
121+
122+
export default DraggableWrapper

src/Common/DraggableWrapper/types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ export interface DraggableWrapperProps {
3737
parentRef?: RefObject<HTMLDivElement>
3838
boundaryGap?: number
3939
childDivProps?: HTMLAttributes<HTMLDivElement>
40-
/**
41-
* Delta for fixing the scrollable layout positioning
42-
* @deprecated
43-
*/
44-
layoutFixDelta?: number
4540
}
4641

4742
/**

0 commit comments

Comments
 (0)