Skip to content

Commit

Permalink
Merge pull request #40 from the-spyke/highlight-selected-option
Browse files Browse the repository at this point in the history
Add class for currently selected item
  • Loading branch information
bvaughn authored Jan 15, 2017
2 parents 3e44736 + 084ee24 commit 9b11bc2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/VirtualizedSelect/VirtualizedSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class VirtualizedSelect extends Component {
}
}

_optionRenderer ({ focusedOption, focusOption, key, labelKey, option, selectValue, style }) {
_optionRenderer ({ focusedOption, focusOption, key, labelKey, option, selectValue, style, valueArray }) {
const className = ['VirtualizedSelectOption']

if (option === focusedOption) {
Expand All @@ -151,6 +151,10 @@ export default class VirtualizedSelect extends Component {
className.push('VirtualizedSelectDisabledOption')
}

if (valueArray && valueArray.indexOf(option) >= 0) {
className.push('VirtualizedSelectSelectedOption')
}

const events = option.disabled
? {}
: {
Expand Down
3 changes: 3 additions & 0 deletions source/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
.VirtualizedSelectDisabledOption {
opacity: 0.5;
}
.VirtualizedSelectSelectedOption {
font-weight: bold;
}
3 changes: 3 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
.VirtualizedSelectDisabledOption {
opacity: 0.5;
}
.VirtualizedSelectSelectedOption {
font-weight: bold;
}

0 comments on commit 9b11bc2

Please sign in to comment.