diff --git a/bower.json b/bower.json index 3b170120..4c7b7f8d 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/package.json b/package.json index de4c7011..88b80c43 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/reorderable.js b/reorderable.js index cb23a5e0..598b94f6 100644 --- a/reorderable.js +++ b/reorderable.js @@ -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 @@ -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,