Skip to content

Commit e93e64b

Browse files
committed
fix key up/down bound issue
fix key up/down bound issue
1 parent 19805e6 commit e93e64b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

components/Dropdown/Dropdown.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ class Dropdown extends React.Component {
3131
return
3232
}
3333
childSelectionIndex += 1
34-
if (childSelectionIndex > listChild.length) {
35-
childSelectionIndex = 0
34+
if (childSelectionIndex >= listChild.length) {
35+
childSelectionIndex -= 1
36+
} else {
37+
listChild[childSelectionIndex].focus()
3638
}
37-
listChild[childSelectionIndex].focus()
3839
}
3940
const focusOnPreviousChild = () => {
4041
const listChild = this.listRef.getElementsByTagName('li')
@@ -43,9 +44,10 @@ class Dropdown extends React.Component {
4344
}
4445
childSelectionIndex -= 1
4546
if (childSelectionIndex < 0) {
46-
childSelectionIndex = listChild.length - 1
47+
childSelectionIndex = 0
48+
} else {
49+
listChild[childSelectionIndex].focus()
4750
}
48-
listChild[childSelectionIndex].focus()
4951
}
5052
let searchKey = ''
5153
let timer

0 commit comments

Comments
 (0)