Skip to content

Commit a2d64e1

Browse files
authored
Block: Move drag handling to instance-bound handler (#4582)
1 parent 6c256dd commit a2d64e1

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

editor/components/block-list/block.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class BlockListBlock extends Component {
104104
this.stopTypingOnMouseMove = this.stopTypingOnMouseMove.bind( this );
105105
this.mergeBlocks = this.mergeBlocks.bind( this );
106106
this.onFocus = this.onFocus.bind( this );
107+
this.preventDrag = this.preventDrag.bind( this );
107108
this.onPointerDown = this.onPointerDown.bind( this );
108109
this.onKeyDown = this.onKeyDown.bind( this );
109110
this.onBlockError = this.onBlockError.bind( this );
@@ -280,6 +281,18 @@ export class BlockListBlock extends Component {
280281
}
281282
}
282283

284+
/**
285+
* Prevents default dragging behavior within a block to allow for multi-
286+
* selection to take effect unhampered.
287+
*
288+
* @param {DragEvent} event Drag event.
289+
*
290+
* @returns {void}
291+
*/
292+
preventDrag( event ) {
293+
event.preventDefault();
294+
}
295+
283296
onPointerDown( event ) {
284297
// Not the main button.
285298
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
@@ -407,7 +420,7 @@ export class BlockListBlock extends Component {
407420
<div
408421
ref={ this.bindBlockNode }
409422
onKeyPress={ this.maybeStartTyping }
410-
onDragStart={ ( event ) => event.preventDefault() }
423+
onDragStart={ this.preventDrag }
411424
onMouseDown={ this.onPointerDown }
412425
onKeyDown={ this.onKeyDown }
413426
onFocus={ this.onFocus }

0 commit comments

Comments
 (0)