Skip to content

Commit

Permalink
Preserve cell edit state and focus after dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed May 4, 2020
1 parent 44fe366 commit 5de0ef6
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export class CellDragAndDropController {

const location = this.getDropInsertLocation(templateData, event);
if (location) {
this.notebookEditor.moveCell(draggedCell, templateData.currentRenderedCell!, location);
this.moveCell(draggedCell, templateData.currentRenderedCell!, location);
container.classList.remove(DRAGOVER_TOP_CLASS, DRAGOVER_BOTTOM_CLASS);
}
}));
Expand All @@ -565,6 +565,12 @@ export class CellDragAndDropController {
}));
}

private moveCell(draggedCell: ICellViewModel, ontoCell: ICellViewModel, location: 'above' | 'below') {
const editState = draggedCell.editState;
this.notebookEditor.moveCell(draggedCell, ontoCell, location);
this.notebookEditor.focusNotebookCell(draggedCell, editState === CellEditState.Editing);
}

private getDropInsertLocation(templateData: BaseCellRenderTemplate, event: DragEvent): 'above' | 'below' | undefined {
if (templateData.currentRenderedCell === this.currentDraggedCell) {
return;
Expand Down

0 comments on commit 5de0ef6

Please sign in to comment.