Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

An accessible select box component for React.

Improvements:
* allow each Option to have a distinct style (using className)
* render each selected Option with a distinct style (using className)

## Screenshots

![screenshot](https://github.com/dungsaga/react-select-box/raw/gh-pages/screenshots/Notable-operating-systems.png)

## Demo

[http://instructure-react.github.io/react-select-box/](http://instructure-react.github.io/react-select-box/)
Expand Down
14 changes: 9 additions & 5 deletions lib/select-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = React.createClass({displayName: 'exports',
} else {
this.updatePendingValue(val, cb) || this.props.onChange(val)
this.handleClose()
this.refs.button.getDOMNode().focus()
this.refs.button.focus()
}
}.bind(this)
},
Expand Down Expand Up @@ -141,7 +141,7 @@ module.exports = React.createClass({displayName: 'exports',
handleOpen: function (event) {
interceptEvent(event)
this.setState({open: true}, function () {
this.refs.menu.getDOMNode().focus()
this.refs.menu.focus()
})
},

Expand Down Expand Up @@ -209,10 +209,10 @@ module.exports = React.createClass({displayName: 'exports',
.filter(function (option) {
return this.isSelected(option.value)
}.bind(this))
.map(function (option) {
return option.label
.map(function (option, i) {
return label({ key: i, className: option.className }, option.label)
})
return selected.length > 0 ? selected.join(', ') : this.props.label
return selected.length > 0 ? selected : this.props.label
},

isMultiple: function () {
Expand All @@ -223,6 +223,7 @@ module.exports = React.createClass({displayName: 'exports',
var options = []
React.Children.forEach(this.props.children, function (option) {
options.push({
className: option.props.className,
value: option.props.value,
label: option.props.children
})
Expand Down Expand Up @@ -350,6 +351,9 @@ module.exports = React.createClass({displayName: 'exports',
if (this.isSelected(option.value)) {
className += ' react-select-box-option-selected'
}
if (option.className) {
className += ' ' + option.className
}
return a(
{
id: this.state.id + '-' + i,
Expand Down