Skip to content

Commit 3e44736

Browse files
author
Brian Vaughn
committed
Added a workaround for a bug in (react-select 1.0.0-rc2).
Clicking on the placeholder item now successfully creates new options. See issue #33.
1 parent 15ffc9f commit 3e44736

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
------------
33

4+
##### 2.1.1
5+
Added a workaround for a bug in `Creatable` (react-select 1.0.0-rc2).
6+
Clicking on the placeholder item now successfully creates new options.
7+
See issue #33.
8+
49
##### 2.1.0
510
Added `listProps` prop to enable pass-through of additional, custom properties to the underlying react-virtualized `List`.
611

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-virtualized-select",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Drop-down menu for React with windowing to support large numbers of options.",
55
"main": "dist/commonjs/index.js",
66
"jsnext:main": "dist/es/index.js",
@@ -106,7 +106,7 @@
106106
"react-addons-shallow-compare": "^15.2.1",
107107
"react-addons-test-utils": "^15.2.1",
108108
"react-dom": "^15.2.1",
109-
"react-select": "^1.0.0-rc.1",
109+
"react-select": "^1.0.0-rc.2",
110110
"react-transform-catch-errors": "^1.0.2",
111111
"react-transform-hmr": "^1.0.2",
112112
"react-virtualized": "^7.23.0",

source/VirtualizedSelect/VirtualizedSelect.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ export default class VirtualizedSelect extends Component {
5050
}
5151

5252
// See https://github.com/JedWatson/react-select/#effeciently-rendering-large-lists-with-windowing
53-
_renderMenu ({ focusedOption, focusOption, labelKey, options, selectValue, valueArray }) {
53+
_renderMenu ({ focusedOption, focusOption, labelKey, onSelect, options, selectValue, valueArray }) {
5454
const { listProps, optionRenderer } = this.props
5555
const focusedOptionIndex = options.indexOf(focusedOption)
5656
const height = this._calculateListHeight({ options })
5757
const innerRowRenderer = optionRenderer || this._optionRenderer
5858

59+
// react-select 1.0.0-rc2 passes duplicate `onSelect` and `selectValue` props to `menuRenderer`
60+
// The `Creatable` HOC only overrides `onSelect` which breaks an edge-case
61+
// In order to support creating items via clicking on the placeholder option,
62+
// We need to ensure that the specified `onSelect` handle is the one we use.
63+
// See issue #33
64+
5965
function wrappedRowRenderer ({ index, key, style }) {
6066
const option = options[index]
6167

@@ -65,10 +71,11 @@ export default class VirtualizedSelect extends Component {
6571
focusOption,
6672
key,
6773
labelKey,
74+
onSelect,
6875
option,
6976
optionIndex: index,
7077
options,
71-
selectValue,
78+
selectValue: onSelect,
7279
style,
7380
valueArray
7481
})

0 commit comments

Comments
 (0)