From d184d00569367e5fe47df467452f49fafbcd1053 Mon Sep 17 00:00:00 2001 From: Lukas Tursky Date: Tue, 30 Oct 2018 16:13:26 +0100 Subject: [PATCH] fix: dragging is disabled if resizing is not allowed (#1072) --- 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 (