fix(list): Don't drag the item being edited. Fixes #1386

This commit is contained in:
Ben Gotow 2016-02-22 17:41:32 -08:00
parent 420bfbd2f6
commit 5412494f0f

View file

@ -119,7 +119,7 @@ class EditableList extends Component {
super(props); super(props);
this.state = props.initialState || { this.state = props.initialState || {
dropInsertionIndex: -1, dropInsertionIndex: -1,
editingIndex: null, editingIndex: -1,
creatingItem: false, creatingItem: false,
}; };
} }
@ -156,7 +156,7 @@ class EditableList extends Component {
}; };
_clearEditingState = (callback)=> { _clearEditingState = (callback)=> {
this._setStateAndFocus({editingIndex: null}, callback); this._setStateAndFocus({editingIndex: -1}, callback);
}; };
_clearCreatingState = (callback)=> { _clearCreatingState = (callback)=> {
@ -288,6 +288,12 @@ class EditableList extends Component {
return; return;
} }
if (row.dataset.itemIdx / 1 === this.state.editingIndex / 1) {
// dragging the row currently being edited makes text selection impossible
event.preventDefault();
return;
}
event.dataTransfer.setData('editablelist-index', row.dataset.itemIdx); event.dataTransfer.setData('editablelist-index', row.dataset.itemIdx);
event.dataTransfer.setData('editablelist-reactid', wrapperId); event.dataTransfer.setData('editablelist-reactid', wrapperId);
event.dataTransfer.effectAllowed = "move"; event.dataTransfer.effectAllowed = "move";