From 0d5ed30cfb6a7e997750825068b454f81c15521c Mon Sep 17 00:00:00 2001 From: xtursky Date: Wed, 7 Nov 2018 13:51:17 +0100 Subject: [PATCH] fix: dragging is disabled if resizing is not allowed (#1072) (#1073) --- src/addons/dragAndDrop/EventWrapper.js | 32 ++++++++++++++------------ 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/addons/dragAndDrop/EventWrapper.js b/src/addons/dragAndDrop/EventWrapper.js index 540491cf4..780088dfa 100644 --- a/src/addons/dragAndDrop/EventWrapper.js +++ b/src/addons/dragAndDrop/EventWrapper.js @@ -89,9 +89,6 @@ class EventWrapper extends React.Component { return children } - let StartAnchor = null - let EndAnchor = null - /* * The resizability of events depends on whether they are * allDay events and how they are displayed. @@ -115,15 +112,7 @@ class EventWrapper extends React.Component { ? !!get(event, resizableAccessor) : true - if (isResizable) { - if (type === 'date') { - StartAnchor = !continuesPrior && this.renderAnchor('Left') - EndAnchor = !continuesAfter && this.renderAnchor('Right') - } else { - StartAnchor = !continuesPrior && this.renderAnchor('Up') - EndAnchor = !continuesAfter && this.renderAnchor('Down') - } - + if (isResizable || isDraggable) { /* * props.children is the singular component. * BigCalendar positions the Event abolutely and we @@ -135,15 +124,28 @@ class EventWrapper extends React.Component { const newProps = { onMouseDown: this.handleStartDragging, onTouchStart: this.handleStartDragging, - // replace original event child with anchor-embellished child + } - children: ( + if (isResizable) { + // replace original event child with anchor-embellished child + let StartAnchor = null + let EndAnchor = null + + if (type === 'date') { + StartAnchor = !continuesPrior && this.renderAnchor('Left') + EndAnchor = !continuesAfter && this.renderAnchor('Right') + } else { + StartAnchor = !continuesPrior && this.renderAnchor('Up') + EndAnchor = !continuesAfter && this.renderAnchor('Down') + } + + newProps.children = (
{StartAnchor} {children.props.children} {EndAnchor}
- ), + ) } if (