From 84e616fc1fcfd991d122516da17518c952ce315d Mon Sep 17 00:00:00 2001 From: goodzsq Date: Tue, 21 Jul 2015 14:35:46 +0800 Subject: [PATCH] Update Select.js fix a allowCreate bug --- src/Select.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Select.js b/src/Select.js index 3a31228189..b1dfb112f0 100644 --- a/src/Select.js +++ b/src/Select.js @@ -648,17 +648,19 @@ var Select = React.createClass({ focusedValue = focusedValue == null ? this.state.filteredOptions[0] : focusedValue; } // Add the current value to the filtered options in last resort + var options = this.state.filteredOptions; if (this.props.allowCreate && this.state.inputValue.trim()) { var inputValue = this.state.inputValue; - this.state.filteredOptions.unshift({ + options = options.slice(); + options.unshift({ value: inputValue, label: inputValue, create: true }); } - var ops = Object.keys(this.state.filteredOptions).map(function(key) { - var op = this.state.filteredOptions[key]; + var ops = Object.keys(options).map(function(key) { + var op = options[key]; var isSelected = this.state.value === op.value; var isFocused = focusedValue === op.value;