Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/react-data-grid/src/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ class Row extends React.Component {
}

handleDragEnter = (e) => {
e.dataTransfer.dropEffect = 'move';
// Prevent default to allow drop
e.preventDefault();
const { idx, cellMetaData: { onDragEnter } } = this.props;
onDragEnter({ overRowIdx: idx });
};

handleDragOver = (e) => {
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
};

handleDrop = (e) => {
// The default in Firefox is to treat data in dataTransfer as a URL and perform navigation on it, even if the data type used is 'text'
// To bypass this, we need to capture and prevent the drop event.
e.preventDefault();
};

Expand Down Expand Up @@ -154,6 +162,7 @@ class Row extends React.Component {
className={className}
style={style}
onDragEnter={this.handleDragEnter}
onDragOver={this.handleDragOver}
onDrop={this.handleDrop}
>
{
Expand Down
13 changes: 10 additions & 3 deletions packages/react-data-grid/src/masks/InteractionMasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class InteractionMasks extends React.Component {
});
};

dragEnabled = () => {
isDragEnabled = () => {
const { onGridRowsUpdated, onCellsDragged } = this.props;
return this.isSelectedCellEditable() && (isFunction(onGridRowsUpdated) || isFunction(onCellsDragged));
};
Expand All @@ -521,7 +521,14 @@ class InteractionMasks extends React.Component {
const isViewportDragging = e && e.target && e.target.className;
if (idx > -1 && isViewportDragging) {
e.dataTransfer.effectAllowed = 'copy';
e.dataTransfer.setData('text/plain', JSON.stringify({ idx, rowIdx }));
// Setting data is required to make an element draggable in FF
const transferData = JSON.stringify({ idx, rowIdx });
try {
e.dataTransfer.setData('text/plain', transferData);
} catch (ex) {
// IE only supports 'text' and 'URL' for the 'type' argument
e.dataTransfer.setData('text', transferData);
}
this.setState({
draggedPosition: { idx, rowIdx }
});
Expand Down Expand Up @@ -608,7 +615,7 @@ class InteractionMasks extends React.Component {
selectedPosition={selectedPosition}
{...this.getSelectionMaskProps()}
>
{this.dragEnabled() && (
{this.isDragEnabled() && (
<DragHandle
onDragStart={this.handleDragStart}
onDragEnd={this.handleDragEnd}
Expand Down