Skip to content

Commit 2d5f930

Browse files
dsmmckenCopilot
andauthored
fix: rollup rows dropzone area in table sidebar (#2572)
Previous behaviour would grow the drop-zone when an item is picked up, but that expanded area would not actually be droppable. Leading to frustrating ux where it seemed like you dropped an item in the droppable area, but it would revert. The list needs to grow, so that you can place the item above or below any existing items. ![drag_before](https://github.com/user-attachments/assets/a4097c60-cc2a-41cc-82c8-c026af3dfc50) Root cause is DnD doesn't treat that area as droppable unless it is overlapping the list. This change enables the DnD placeholder item, to fill out the expanded area. The list now grows after initial contact rather than before, as that's when the placeholder gets added by DnD. ![drag_after](https://github.com/user-attachments/assets/d7cb7bf9-f890-48c0-88fb-8664e910bb0b) Additionally, added a hover styling to positively show your drop is going to be successful. Ultimately though, this goes away entirely with pivot builder. --------- Co-authored-by: Copilot <[email protected]>
1 parent 6981b5a commit 2d5f930

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

packages/components/src/DraggableItemList.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type DraggableItemListProps<T> = Omit<
3333
className: string;
3434
draggingItemClassName: string;
3535
isDropDisabled: boolean;
36+
// Whether to include the droppable provided.placeholder in the DOM
37+
hasPlaceholder: boolean;
3638
// Whether to allow dragging items from this list
3739
isDragDisabled: boolean;
3840

@@ -73,6 +75,7 @@ class DraggableItemList<T> extends PureComponent<
7375
isDeselectOnClick: true,
7476
isDoubleClickSelect: true,
7577
isDropDisabled: false,
78+
hasPlaceholder: false,
7679
isDragDisabled: false,
7780
isMultiSelect: false,
7881
isStickyBottom: false,
@@ -316,6 +319,7 @@ class DraggableItemList<T> extends PureComponent<
316319
isDoubleClickSelect,
317320
isDragDisabled,
318321
isDropDisabled,
322+
hasPlaceholder,
319323
isMultiSelect,
320324
isStickyBottom,
321325
itemCount,
@@ -380,6 +384,7 @@ class DraggableItemList<T> extends PureComponent<
380384
rowHeight={rowHeight}
381385
selectedRanges={selectedRanges}
382386
/>
387+
{hasPlaceholder && provided.placeholder}
383388
</div>
384389
)}
385390
</Droppable>

packages/iris-grid/src/sidebar/RollupRows.scss

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@
6767

6868
.draggable-item-list {
6969
flex-grow: 1;
70-
transition: height $transition;
70+
// group-list-height assigned from JS
71+
min-height: calc(
72+
var(--group-list-height) + var(--placeholder-height, 0px)
73+
);
7174
}
7275

7376
.btn-delete-grouping {
@@ -81,6 +84,7 @@
8184
padding: $spacer-3;
8285
text-align: center;
8386
border: dashed 1px;
87+
text-wrap: pretty;
8488
}
8589
}
8690

@@ -98,19 +102,43 @@
98102
.rollup-rows-group-by {
99103
.placeholder {
100104
border: dashed 1px transparent;
105+
101106
@include ants-base($foreground, $background);
107+
108+
&.is-dragging-over {
109+
background-color: var(--dh-color-item-list-selected-hover-bg);
110+
}
102111
}
103112

104113
.item-list-scroll-pane {
105114
@include ants-base($foreground, $background);
106115
}
116+
117+
.draggable-item-list.is-dragging-over {
118+
.item-list-scroll-pane {
119+
background-color: var(--dh-color-item-list-selected-hover-bg);
120+
}
121+
122+
&:not(.is-dragging-from-this) {
123+
// placeholder doesn't add height with current AutoSizer
124+
// so add the height of the placeholder manually
125+
// rowHeight variable assigned from JS
126+
--placeholder-height: var(--row-height);
127+
}
128+
}
107129
}
108130

109131
.rollup-rows-available-columns
110132
.draggable-item-list:not(.is-dragging-from-this) {
111133
.item-list-scroll-pane {
112134
@include ants-base($foreground, $background);
113135
}
136+
137+
&.is-dragging-over {
138+
.item-list-scroll-pane {
139+
background-color: var(--dh-color-item-list-selected-hover-bg);
140+
}
141+
}
114142
}
115143
}
116144
}

packages/iris-grid/src/sidebar/RollupRows.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,8 @@ class RollupRows extends Component<RollupRowsProps, RollupRowsState> {
486486
} = this.state;
487487

488488
const ungroupedColumns = this.getSortedUngroupedColumns();
489-
let groupListHeight = columns.length * DraggableItemList.DEFAULT_ROW_HEIGHT;
490-
if (dragSource?.droppableId === UNGROUPED_LIST_ID) {
491-
groupListHeight += DraggableItemList.DEFAULT_ROW_HEIGHT;
492-
}
489+
const groupListHeight =
490+
columns.length * DraggableItemList.DEFAULT_ROW_HEIGHT;
493491
const ungroupMaxListHeight =
494492
ungroupedColumns.length * DraggableItemList.DEFAULT_ROW_HEIGHT + 10;
495493
const ungroupMinListHeight = Math.min(
@@ -542,8 +540,14 @@ class RollupRows extends Component<RollupRowsProps, RollupRowsState> {
542540
ref={this.groupedList}
543541
renderItem={this.renderGroupedItem}
544542
selectedRanges={groupedSelectedRanges}
545-
style={{ height: groupListHeight }}
543+
style={
544+
{
545+
'--group-list-height': `${groupListHeight}px`,
546+
'--row-height': `${DraggableItemList.DEFAULT_ROW_HEIGHT}px`,
547+
} as React.CSSProperties
548+
}
546549
isMultiSelect
550+
hasPlaceholder
547551
/>
548552
)}
549553
</div>

0 commit comments

Comments
 (0)