-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Set drag column image #3783
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Set drag column image #3783
Conversation
amanmahajan7
commented
May 14, 2025
•
edited
Loading
edited
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3783 +/- ##
=======================================
Coverage 98.79% 98.80%
=======================================
Files 46 46
Lines 3497 3507 +10
Branches 763 764 +1
=======================================
+ Hits 3455 3465 +10
Misses 42 42
🚀 New features to boost your workflow:
|
@@ -43,17 +43,29 @@ export const resizeHandleClassname = css` | |||
const cellDraggableClassname = 'rdg-cell-draggable'; | |||
|
|||
const cellDragging = css` | |||
opacity: 0.5; | |||
@layer rdg.HeaderCell { | |||
background-color: var(--rdg-header-draggable-background-color); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kept the same style as cell over for now. We cannot use opacity as we are using a custom drag image
const dragImage = event.currentTarget.cloneNode(true) as HTMLDivElement; | ||
dragImage.classList.add(dragImageClassname); | ||
dragImage.id = dragImageId; | ||
event.currentTarget.parentElement!.insertBefore(dragImage, event.currentTarget); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way the element is behind the column
}; | ||
|
||
if (draggedColumnKey !== undefined && draggedColumnKey !== column.key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we won't fire these events if external item is dragged over
@@ -60,7 +60,7 @@ function HeaderRow<R, SR, K extends React.Key>({ | |||
selectCell, | |||
direction | |||
}: HeaderRowProps<R, SR, K>) { | |||
const dragDropKey = useId(); | |||
const [draggedColumnKey, setDraggedColumnKey] = useState<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can move this to the parent component and reorder columns internally as user is dragging. I will check
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
if (document.startViewTransition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FF does not support this
src/HeaderRow.tsx
Outdated
/> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could keep this newline
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>