File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -51,22 +51,16 @@ function pressUpKey (e) {
51
51
e . preventDefault ( )
52
52
53
53
// if first item, cycle to the bottom
54
- if ( this . state . index <= 0 ) {
55
- this . setState ( { index : this . state . options . length - 1 } )
56
- } else {
57
- this . setState ( { index : this . state . index - 1 } )
58
- }
54
+ const size = this . state . options . length - 1
55
+ this . setState ( { index : this . state . index <= 0 ? size : this . state . index - 1 } )
59
56
}
60
57
61
58
function pressDownKey ( e ) {
62
59
e . preventDefault ( )
63
60
64
61
// if last item, cycle to top
65
- if ( this . state . index >= this . state . options . length - 1 ) {
66
- this . setState ( { index : 0 } )
67
- } else {
68
- this . setState ( { index : this . state . index + 1 } )
69
- }
62
+ const size = this . state . options . length - 1
63
+ this . setState ( { index : this . state . index >= size ? 0 : this . state . index + 1 } )
70
64
}
71
65
72
66
function pressBackspaceKey ( ) {
You can’t perform that action at this time.
0 commit comments