New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove InteractionMask #2061
Remove InteractionMask #2061
Changes from 3 commits
1b998a3
2eaa5a0
b085271
1bc4eca
54de1df
85d95a2
66b0dfc
526fa66
0600a9f
a596653
888dd59
362414e
36d0ce9
ff7d61e
34f11c1
c024ae7
f9b9151
5e355ed
c4b6ad7
787ab44
9404987
1b8c3a5
a9a2613
336c793
ac2c630
57ec91d
0504d29
3cc29bd
de4248a
3acd681
1c53773
689c727
a4beb50
86ca94b
ba7d7e3
5a5b9fe
a4ecddf
eda56d0
9011686
421d265
6ffb06a
4eb1100
c8cb194
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,11 +469,7 @@ function DataGrid<R, K extends keyof R, SR>({ | |
} | ||
} | ||
|
||
function handleMouseDown(event: React.MouseEvent<HTMLDivElement>) { | ||
if (!enableCellDragAndDrop) return; | ||
const { target } = event; | ||
if (!(target instanceof HTMLDivElement && target.className === 'rdg-cell-drag-handle')) return; | ||
|
||
function handleMouseDown() { | ||
setDragging(true); | ||
window.addEventListener('mouseover', onMouseover); | ||
window.addEventListener('mouseup', onMouseup); | ||
|
@@ -493,10 +489,6 @@ function DataGrid<R, K extends keyof R, SR>({ | |
} | ||
|
||
function handleDoubleClick(event: React.MouseEvent<HTMLDivElement>) { | ||
if (!enableCellDragAndDrop) return; | ||
const { target } = event; | ||
if (!(target instanceof HTMLDivElement && target.className === 'rdg-cell-drag-handle')) return; | ||
|
||
event.stopPropagation(); | ||
|
||
const column = columns[selectedPosition.idx]; | ||
|
@@ -639,6 +631,17 @@ function DataGrid<R, K extends keyof R, SR>({ | |
); | ||
} | ||
|
||
function getDragHandle() { | ||
if (!enableCellDragAndDrop || !isCellEditable(selectedPosition) || selectedPosition.mode === 'EDIT') return null; | ||
return ( | ||
<div | ||
className="rdg-cell-drag-handle" | ||
onMouseDown={handleMouseDown} | ||
onDoubleClick={handleDoubleClick} | ||
/> | ||
); | ||
} | ||
|
||
function getViewportRows() { | ||
const rowElements = []; | ||
|
||
|
@@ -670,6 +673,7 @@ function DataGrid<R, K extends keyof R, SR>({ | |
rowClass={rowClass} | ||
top={rowIdx * rowHeight + totalHeaderHeight} | ||
setDraggedOverRowIdx={isDragging ? setDraggedOverRowIdx : undefined} | ||
dragHandle={selectedPosition.rowIdx === rowIdx ? getDragHandle() : undefined} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks weird combining this condition with the checks inside the dragHandle={displayDragHandle() ? getDragHandle() : undefined} // remove the checks from getDragHandle or completely move all conditions inside function getDragHandle() {
if (selectedPosition.rowIdx !== rowIdx || !enableCellDragAndDrop || !isCellEditable(selectedPosition) || selectedPosition.mode === 'EDIT') return null;
... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is fine. We need to add dragHandle only on the row that has the selected position. I will have to change the signature otherwise There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Qi. We can also do |
||
/> | ||
); | ||
} | ||
|
@@ -724,8 +728,6 @@ function DataGrid<R, K extends keyof R, SR>({ | |
<div | ||
className={clsx({ 'rdg-viewport-dragging': isDragging })} | ||
onKeyDown={handleKeyDown} | ||
onMouseDown={handleMouseDown} | ||
onDoubleClick={handleDoubleClick} | ||
> | ||
{viewportWidth > 0 && getViewportRows()} | ||
{getEditorContainer()} | ||
amanmahajan7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.highlight { | ||
.highlight .rdg-cell { | ||
background-color: #9370DB; | ||
color: white; | ||
} | ||
|
||
.rdg-row.highlight:hover { | ||
.highlight:hover .rdg-cell { | ||
background-color: #800080; | ||
} |
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.
Maybe we should check that we initiate dragging with the primary mouse button, so we can at least avoid a re-render.