diff --git a/packages/xod-client/src/editor/containers/Patch/dropTarget.js b/packages/xod-client/src/editor/containers/Patch/dropTarget.js index ecb363cb..ba8ce5c8 100644 --- a/packages/xod-client/src/editor/containers/Patch/dropTarget.js +++ b/packages/xod-client/src/editor/containers/Patch/dropTarget.js @@ -32,9 +32,11 @@ const dropTarget = { ); component.goToDefaultMode(); }, - hover(props, monitor, component) { // TODO: performance? + hover(props, monitor, component) { if (!component.dropTargetRootRef) return; + if (!monitor.isOver()) return; + component.setModeStateThrottled( EDITOR_MODE.ACCEPTING_DRAGGED_PATCH, { previewPosition: getDraggedPatchPosition(props, monitor, component) } diff --git a/packages/xod-client/src/editor/containers/Patch/index.jsx b/packages/xod-client/src/editor/containers/Patch/index.jsx index 026f2811..2e636d60 100644 --- a/packages/xod-client/src/editor/containers/Patch/index.jsx +++ b/packages/xod-client/src/editor/containers/Patch/index.jsx @@ -82,6 +82,11 @@ class Patch extends React.Component { ) { this.dropTargetRootRef.firstChild.focus(); } + + // patch was dragged out + if (!this.props.isPatchDraggedOver && prevProps.isPatchDraggedOver) { + this.goToDefaultMode(); + } } getApi(mode) { @@ -157,6 +162,7 @@ Patch.propTypes = { onDoubleClick: PropTypes.func.isRequired, connectDropTarget: PropTypes.func.isRequired, isDebugSession: PropTypes.bool, + isPatchDraggedOver: PropTypes.bool, nodeValues: PropTypes.objectOf(PropTypes.string), /* eslint-enable react/no-unused-prop-types */ };