Skip to content

Commit

Permalink
now calling dimension publisher first when drag is ending (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon authored Mar 13, 2018
1 parent e8da50f commit 702f699
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/view/drag-drop-context/drag-drop-context.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ export default class DragDropContext extends React.Component<Props> {
this.styleMarshal.onPhaseChange(current);
}

const isDragEnding: boolean = current.phase !== 'DRAGGING' && previousInThisExecution.phase === 'DRAGGING';

// in the case that a drag is ending we need to instruct the dimension marshal
// to stop listening to changes. Otherwise it will try to process
// changes after the reorder in onDragEnd
if (isDragEnding) {
this.dimensionMarshal.onPhaseChange(current);
}

// We recreate the Hook object so that consumers can pass in new
// hook props at any time (eg if they are using arrow functions)
const hooks: Hooks = {
Expand All @@ -183,7 +192,8 @@ export default class DragDropContext extends React.Component<Props> {
// create new actions that update the application state. That will cause
// this subscription function to be called again before the next line is called.

if (isPhaseChanging) {
// if isDragEnding we have already called the marshal
if (isPhaseChanging && !isDragEnding) {
this.dimensionMarshal.onPhaseChange(current);
}

Expand Down

0 comments on commit 702f699

Please sign in to comment.