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.
This commit is contained in:
Matthew Dapena-Tretter
2018-03-12 11:31:19 -07:00
parent 31e9ddad1e
commit 5af205739d

View File

@@ -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