From 5af205739d72c6f6ed03440d3a6d93b77fb14b7c Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Mon, 12 Mar 2018 11:31:19 -0700 Subject: [PATCH] Don't trigger dock handle drag enter event unless a known item is being dragged This seems a little counterintuitive. How could a dragenter event fire if nothing's being dragged? Well, if something's dragged into the document (i.e. from the desktop or another window), a dragenter event will be fired even though (as far as we're concerned), nothing is being dragged. Rather than trying to handle this class of events specially in the dock, we simply limit our listening to when something is being dragged. Since we have a single source of truth for this information, this should be resilient to future changes in logic. --- src/dock.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dock.js b/src/dock.js index 99026e550..7ed18972c 100644 --- a/src/dock.js +++ b/src/dock.js @@ -233,7 +233,7 @@ module.exports = class Dock { ), $(DockToggleButton, { ref: 'toggleButton', - onDragEnter: this.handleToggleButtonDragEnter, + onDragEnter: this.state.draggingItem ? this.handleToggleButtonDragEnter : null, location: this.location, toggle: this.toggle, dockIsVisible: shouldBeVisible, @@ -779,7 +779,10 @@ class DockToggleButton { { ref: 'innerElement', className: `atom-dock-toggle-button-inner ${this.props.location}`, - on: {click: this.handleClick, dragenter: this.handleDragEnter} + on: { + click: this.handleClick, + dragenter: this.props.onDragEnter + } }, $.span({ ref: 'iconElement', @@ -808,10 +811,6 @@ class DockToggleButton { handleClick () { this.props.toggle() } - - handleDragEnter () { - this.props.onDragEnter() - } } // An etch component that doesn't use etch, this component provides a gateway from JSX back into