Skip to content

Commit 8ccfb5d

Browse files
committed
fix(Board and Lane Dragging Restrictions): Should restrict dragging lanes or cards across boards
#136
1 parent 6e752f4 commit 8ccfb5d

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

src/components/BoardContainer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ class BoardContainer extends Component {
110110
}
111111
}
112112

113+
get groupName() {
114+
const {id} = this.props
115+
return `TrelloBoard${id}`
116+
}
117+
113118
render() {
114119
const {id, reducerData, draggable, laneDraggable, laneDragClass, style, addLaneTitle, editable, canAddLanes, ...otherProps} = this.props
115120
const {addLaneMode} = this.state
@@ -150,12 +155,13 @@ class BoardContainer extends Component {
150155
onDrop={this.onLaneDrop}
151156
lockAxis="x"
152157
getChildPayload={index => this.getLaneDetails(index)}
153-
groupName={`TrelloBoard${id}`}>
158+
groupName={this.groupName}>
154159
{reducerData.lanes.map((lane, index) => {
155160
const {id, droppable, ...otherProps} = lane
156161
const laneToRender = (
157162
<Lane
158163
key={id}
164+
boardId={this.groupName}
159165
id={id}
160166
getCardDetails={this.getCardDetails}
161167
index={index}

src/components/Lane.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ class Lane extends Component {
127127
}
128128

129129
shouldAcceptDrop = sourceContainerOptions => {
130-
return this.props.droppable && sourceContainerOptions.groupName === 'TrelloLane'
130+
return this.props.droppable && sourceContainerOptions.groupName === this.groupName
131+
}
132+
133+
get groupName() {
134+
const {boardId} = this.props
135+
return `TrelloBoard${boardId}Lane`
131136
}
132137

133138
onDragEnd = (laneId, result) => {
@@ -189,7 +194,7 @@ class Lane extends Component {
189194
<ScrollableLane innerRef={this.laneDidMount} isDraggingOver={isDraggingOver}>
190195
<Container
191196
orientation="vertical"
192-
groupName="TrelloLane"
197+
groupName={this.groupName}
193198
dragClass={cardDragClass}
194199
onDragStart={this.onDragStart}
195200
onDrop={e => this.onDragEnd(id, e)}
@@ -255,6 +260,7 @@ Lane.propTypes = {
255260
actions: PropTypes.object,
256261
children: PropTypes.node,
257262
id: PropTypes.string.isRequired,
263+
boardId: PropTypes.string,
258264
title: PropTypes.node,
259265
index: PropTypes.number,
260266
laneSortFunction: PropTypes.func,

src/dnd/Container.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import React, { Component } from 'react';
1+
import React, {Component} from 'react'
22
import ReactDOM from 'react-dom'
3-
import PropTypes from 'prop-types';
4-
import container from 'smooth-dnd';
5-
import { dropHandlers } from 'smooth-dnd';
6-
import Draggable from './Draggable';
3+
import PropTypes from 'prop-types'
4+
import container, {dropHandlers} from 'smooth-dnd'
75

86
container.dropHandler = dropHandlers.reactDropHandler().handler;
97
container.wrapChild = p => p; // dont wrap children they will already be wrapped
@@ -88,4 +86,4 @@ Container.defaultProps = {
8886
orientation: 'vertical'
8987
};
9088

91-
export default Container;
89+
export default Container;

src/dnd/Draggable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Draggable.propTypes = {
2424
render: PropTypes.func
2525
};
2626

27-
export default Draggable;
27+
export default Draggable;

stories/MultipleBoards.story.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ storiesOf('Multiple Boards', module).add(
1818
return (
1919
<div style={{display: 'flex', flexDirection: 'column'}}>
2020
<div style={containerStyles}>
21-
<Board data={data1} draggable />
21+
<Board id="board1" data={data1} draggable />
2222
</div>
2323
<div style={containerStyles}>
24-
<Board data={data2} draggable />
24+
<Board id="board2" data={data2} draggable />
2525
</div>
2626
</div>
2727
)

0 commit comments

Comments
 (0)