Skip to content

Commit

Permalink
Highlight selected item
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeSidSmith committed Jan 27, 2015
1 parent ddc6152 commit 0dc90d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-reorderable",
"version": "1.1.0",
"version": "1.2.0",
"description": "Drag & drop, touch enabled, reorderable / sortable list, React component",
"homepage": "https://github.com/JakeSidSmith/react-reorderable",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-reorderable",
"version": "1.1.0",
"version": "1.2.0",
"description": "Drag & drop, touch enabled, reorderable / sortable list, React component",
"author": "Jake 'Sid' Smith",
"license": "MIT",
Expand Down
11 changes: 10 additions & 1 deletion reorderable.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,15 @@
}
return undefined;
},
getSelectedClass: function (item) {
if (typeof this.props.selected !== 'undefined') {
if (typeof this.props.selectedKey !== 'undefined') {
return this.props.selected[this.props.selectedKey] === item[this.props.selectedKey] ? 'selected' : undefined;
}
return this.props.selected === item ? 'selected' : undefined;
}
return undefined;
},

// ---- Default methods

Expand Down Expand Up @@ -457,7 +466,7 @@

var list = this.state.list.map(function (item, index) {
var itemKey = item[self.props.itemKey] || item;
var itemClass = [self.props.itemClass, self.getPlaceholderClass(item)].join(' ');
var itemClass = [self.props.itemClass, self.getPlaceholderClass(item), self.getSelectedClass(item)].join(' ');
return React.createElement('div', {
key: itemKey,
className: itemClass,
Expand Down

0 comments on commit 0dc90d0

Please sign in to comment.