@@ -35,7 +35,7 @@ class ReactTags extends React.Component {
35
35
query : '' ,
36
36
focused : false ,
37
37
expanded : false ,
38
- selectedIndex : - 1 ,
38
+ selected : - 1 ,
39
39
classNames : Object . assign ( { } , CLASS_NAMES , this . props . classNames )
40
40
}
41
41
}
@@ -57,12 +57,12 @@ class ReactTags extends React.Component {
57
57
}
58
58
59
59
onKeyDown ( e ) {
60
- const { query, selectedIndex } = this . state
60
+ const { query, selected } = this . state
61
61
const { delimiters } = this . props
62
62
63
63
// when one of the terminating keys is pressed, add current query to the tags.
64
64
if ( delimiters . indexOf ( e . key ) > - 1 ) {
65
- if ( query || selectedIndex > - 1 ) {
65
+ if ( query || selected > - 1 ) {
66
66
e . preventDefault ( )
67
67
}
68
68
@@ -72,7 +72,7 @@ class ReactTags extends React.Component {
72
72
suggestion . name . search ( new RegExp ( `^${ query } $` , 'i' ) ) === 0
73
73
) )
74
74
75
- const index = selectedIndex === - 1 ? match : selectedIndex
75
+ const index = selected === - 1 ? match : selected
76
76
77
77
if ( index > - 1 ) {
78
78
this . addTag ( this . suggestions . state . options [ index ] )
@@ -91,17 +91,17 @@ class ReactTags extends React.Component {
91
91
e . preventDefault ( )
92
92
93
93
// if last item, cycle to the bottom
94
- if ( selectedIndex <= 0 ) {
95
- this . setState ( { selectedIndex : this . suggestions . state . options . length - 1 } )
94
+ if ( selected <= 0 ) {
95
+ this . setState ( { selected : this . suggestions . state . options . length - 1 } )
96
96
} else {
97
- this . setState ( { selectedIndex : selectedIndex - 1 } )
97
+ this . setState ( { selected : selected - 1 } )
98
98
}
99
99
}
100
100
101
101
if ( e . key === KEYS . DOWN_ARROW ) {
102
102
e . preventDefault ( )
103
103
104
- this . setState ( { selectedIndex : ( selectedIndex + 1 ) % this . suggestions . state . options . length } )
104
+ this . setState ( { selected : ( selected + 1 ) % this . suggestions . state . options . length } )
105
105
}
106
106
}
107
107
@@ -112,7 +112,7 @@ class ReactTags extends React.Component {
112
112
}
113
113
114
114
onBlur ( ) {
115
- this . setState ( { focused : false , selectedIndex : - 1 } )
115
+ this . setState ( { focused : false , selected : - 1 } )
116
116
117
117
if ( this . props . onBlur ) {
118
118
this . props . onBlur ( )
@@ -137,7 +137,7 @@ class ReactTags extends React.Component {
137
137
// reset the state
138
138
this . setState ( {
139
139
query : '' ,
140
- selectedIndex : - 1
140
+ selected : - 1
141
141
} )
142
142
}
143
143
@@ -171,10 +171,10 @@ class ReactTags extends React.Component {
171
171
</ div >
172
172
< div
173
173
className = { this . state . classNames . search }
174
- onBlurCapture = { this . onBlur . bind ( this ) }
175
174
onFocusCapture = { this . onFocus . bind ( this ) }
176
- onInput = { this . onInput . bind ( this ) }
177
- onKeyDown = { this . onKeyDown . bind ( this ) } >
175
+ onBlurCapture = { this . onBlur . bind ( this ) }
176
+ onKeyDown = { this . onKeyDown . bind ( this ) }
177
+ onInput = { this . onInput . bind ( this ) } >
178
178
< Input { ...this . state }
179
179
ref = { ( c ) => { this . input = c } }
180
180
listboxId = { listboxId }
0 commit comments