File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -112,8 +112,17 @@ const factory = (Chip, Input) => {
112
112
} ;
113
113
114
114
handleQueryKeyUp = ( event ) => {
115
- if ( event . which === 13 && this . state . active ) this . select ( this . state . active , event ) ;
115
+ if ( event . which === 13 ) {
116
+ let target = this . state . active ;
117
+ if ( ! target ) {
118
+ target = [ ...this . suggestions ( ) . keys ( ) ] [ 0 ] ;
119
+ this . setState ( { active : target } ) ;
120
+ }
121
+ this . select ( target , event ) ;
122
+ }
123
+
116
124
if ( event . which === 27 ) ReactDOM . findDOMNode ( this ) . querySelector ( 'input' ) . blur ( ) ;
125
+
117
126
if ( [ 40 , 38 ] . indexOf ( event . which ) !== - 1 ) {
118
127
const suggestionsKeys = [ ...this . suggestions ( ) . keys ( ) ] ;
119
128
let index = suggestionsKeys . indexOf ( this . state . active ) + ( event . which === 40 ? + 1 : - 1 ) ;
Original file line number Diff line number Diff line change @@ -100,8 +100,17 @@ var factory = function factory(Chip, Input) {
100
100
_this . setState ( { query : '' } ) ;
101
101
}
102
102
} , _this . handleQueryKeyUp = function ( event ) {
103
- if ( event . which === 13 && _this . state . active ) _this . select ( _this . state . active , event ) ;
103
+ if ( event . which === 13 ) {
104
+ var target = _this . state . active ;
105
+ if ( ! target ) {
106
+ target = [ ] . concat ( _toConsumableArray ( _this . suggestions ( ) . keys ( ) ) ) [ 0 ] ;
107
+ _this . setState ( { active : target } ) ;
108
+ }
109
+ _this . select ( target , event ) ;
110
+ }
111
+
104
112
if ( event . which === 27 ) _reactDom2 . default . findDOMNode ( _this ) . querySelector ( 'input' ) . blur ( ) ;
113
+
105
114
if ( [ 40 , 38 ] . indexOf ( event . which ) !== - 1 ) {
106
115
var suggestionsKeys = [ ] . concat ( _toConsumableArray ( _this . suggestions ( ) . keys ( ) ) ) ;
107
116
var index = suggestionsKeys . indexOf ( _this . state . active ) + ( event . which === 40 ? + 1 : - 1 ) ;
You can’t perform that action at this time.
0 commit comments