Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dragging is disabled if resizing is not allowed #1073

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions src/addons/dragAndDrop/EventWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 <Event> component.
* BigCalendar positions the Event abolutely and we
Expand All @@ -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 = (
<div className="rbc-addons-dnd-resizable">
{StartAnchor}
{children.props.children}
{EndAnchor}
</div>
),
)
}

if (
Expand Down