Skip to content

Commit 68598f2

Browse files
committed
fix: Make lane and card dragging work for multiple boards scenarios
#87
1 parent 87f4a85 commit 68598f2

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/components/Board.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import {Provider} from 'react-redux'
44
import {createStore, applyMiddleware} from 'redux'
55
import boardReducer from '../reducers/BoardReducer'
66
import logger from 'redux-logger'
7+
import uuidv1 from "uuid/v1"
78

89
const middlewares = process.env.NODE_ENV === 'development' ? [logger] : []
910

1011
export default class Board extends Component {
1112
constructor() {
1213
super()
13-
1414
this.store = this.getStore();
15+
this.id = uuidv1()
1516
}
1617

1718
getStore = () => {
@@ -22,7 +23,7 @@ export default class Board extends Component {
2223
render() {
2324
return (
2425
<Provider store={this.store}>
25-
<BoardContainer {...this.props} />
26+
<BoardContainer {...this.props} id={this.id}/>
2627
</Provider>
2728
)
2829
}

src/components/BoardContainer.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class BoardContainer extends Component {
7878
}
7979

8080
render() {
81-
const {reducerData, draggable, laneDraggable, laneDragClass, style, ...otherProps} = this.props
81+
const {id, reducerData, draggable, laneDraggable, laneDragClass, style, ...otherProps} = this.props
8282
// Stick to whitelisting attributes to segregate board and lane props
8383
const passthroughProps = pick(this.props, [
8484
'onLaneScroll',
@@ -112,7 +112,7 @@ class BoardContainer extends Component {
112112
onDrop={this.onLaneDrop}
113113
lockAxis={'x'}
114114
getChildPayload={index => this.getLaneDetails(index)}
115-
groupName="TrelloBoard">
115+
groupName={`TrelloBoard${id}`}>
116116
{reducerData.lanes.map((lane, index) => {
117117
const {id, droppable, ...otherProps} = lane
118118
const laneToRender = (
@@ -139,6 +139,7 @@ class BoardContainer extends Component {
139139
}
140140

141141
BoardContainer.propTypes = {
142+
id: PropTypes.string,
142143
actions: PropTypes.object,
143144
data: PropTypes.object.isRequired,
144145
reducerData: PropTypes.object,

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} />
21+
<Board data={data1} draggable />
2222
</div>
2323
<div style={containerStyles}>
24-
<Board data={data2} />
24+
<Board data={data2} draggable />
2525
</div>
2626
</div>
2727
)

0 commit comments

Comments
 (0)