Skip to content

Commit 8e6da84

Browse files
committed
add split-top option on RowDropArea
1 parent e0176b1 commit 8e6da84

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

packages/ui/src/elements/TreeView/NestedSectionsTable/RowDropArea/index.scss

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
z-index: 1;
1515
}
1616

17-
&--on-split {
18-
bottom: 0;
19-
transform: translateY(50%);
17+
&--on-split-bottom,
18+
&--on-split-top {
2019
min-width: unset;
2120

2221
&.is-dragging.is-over {
@@ -26,6 +25,16 @@
2625
}
2726
}
2827
}
28+
29+
&--on-split-bottom {
30+
bottom: 0;
31+
transform: translateY(50%);
32+
}
33+
34+
&--on-split-top {
35+
top: 0;
36+
transform: translateY(-50%);
37+
}
2938
}
3039

3140
.row-drop-area__split-marker {

packages/ui/src/elements/TreeView/NestedSectionsTable/RowDropArea/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const baseClass = 'row-drop-area'
1010
const DEFAULT_SEGMENT_WIDTH = 30
1111
const THROTTLE_MS = 16
1212

13-
type Placement = 'middle' | 'split'
13+
type Placement = 'middle' | 'split-bottom' | 'split-top'
1414

1515
export type RowDropAreaProps = {
1616
disabled?: boolean
@@ -30,7 +30,7 @@ export const RowDropArea = ({
3030
dropContextName,
3131
isDragging = false,
3232
onHover,
33-
placement = 'split',
33+
placement = 'split-bottom',
3434
segmentWidth = DEFAULT_SEGMENT_WIDTH,
3535
style,
3636
targetItems = [],
@@ -83,7 +83,7 @@ export const RowDropArea = ({
8383
width: '100%',
8484
}}
8585
>
86-
{placement === 'split' && (
86+
{(placement === 'split-bottom' || placement === 'split-top') && (
8787
<div
8888
className={`${baseClass}__split-marker`}
8989
style={{

packages/ui/src/elements/TreeView/NestedSectionsTable/index.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,27 @@ export const DivTableSection: React.FC<DivTableSectionProps> = ({
387387
),
388388
)}
389389
<div>
390+
{/* Add split-top drop area for first root-level row */}
391+
{level === 0 && sectionRowIndex === 0 && (
392+
<RowDropArea
393+
disabled={isInvalidTarget}
394+
dropContextName={dropContextName}
395+
isDragging={isDragging}
396+
onHover={(data) => {
397+
onDroppableHover({ ...data, hoveredRowID: rowItem.rowID })
398+
}}
399+
placement="split-top"
400+
segmentWidth={segmentWidth}
401+
style={{
402+
left: 0,
403+
width: '100%',
404+
}}
405+
targetItems={[null]}
406+
xDragOffset={firstCellXOffset + firstCellWidth + 28}
407+
xSplitOffset={`calc(${firstCellWidth + 28}px + var(--cell-inline-padding-start))`}
408+
/>
409+
)}
410+
{/* Add row-drop-area on row */}
390411
<RowDropArea
391412
disabled={isInvalidTarget}
392413
dropContextName={dropContextName}
@@ -399,15 +420,15 @@ export const DivTableSection: React.FC<DivTableSectionProps> = ({
399420
style={{ left: 0, width: '100%' }}
400421
targetItems={[rowItem]}
401422
/>
402-
423+
{/* Add split-bottom drop area on row */}
403424
<RowDropArea
404425
disabled={isInvalidTarget}
405426
dropContextName={dropContextName}
406427
isDragging={isDragging}
407428
onHover={(data) => {
408429
onDroppableHover({ ...data, hoveredRowID: rowItem.rowID })
409430
}}
410-
placement="split"
431+
placement="split-bottom"
411432
segmentWidth={segmentWidth}
412433
style={{
413434
left: 0,

0 commit comments

Comments
 (0)