change counter variable name

This commit is contained in:
KDSBrowne 2017-06-05 12:08:34 -07:00
parent 3ffc7f34f8
commit 26b40e9fb0
2 changed files with 10 additions and 10 deletions

View File

@ -25,7 +25,7 @@ export default class DropdownList extends Component {
this.childrenRefs = [];
this.handleItemKeyDown = this.handleItemKeyDown.bind(this);
this.handleItemClick = this.handleItemClick.bind(this);
this.counter = 0;
this.focusedItemIndex = 0;
}
componentWillMount() {
@ -63,7 +63,7 @@ export default class DropdownList extends Component {
event.preventDefault();
event.stopPropagation();
selectableItems[this.counter].focus();
selectableItems[this.focusedItemIndex].focus();
}
if ([KEY_CODES.ENTER, KEY_CODES.SPACE].includes(event.keyCode)) {
@ -74,20 +74,20 @@ export default class DropdownList extends Component {
}
if (KEY_CODES.ARROW_DOWN === event.which) {
this.counter += 1;
this.focusedItemIndex += 1;
if (!selectableItems[this.counter]) {
this.counter = 0;
if (!selectableItems[this.focusedItemIndex]) {
this.focusedItemIndex = 0;
}
focusMenuItem();
}
if (KEY_CODES.ARROW_UP === event.which) {
this.counter -= 1;
this.focusedItemIndex -= 1;
if (this.counter < 0) {
this.counter = selectableItems.length - 1;
if (this.focusedItemIndex < 0) {
this.focusedItemIndex = selectableItems.length - 1;
}
focusMenuItem();

View File

@ -93,7 +93,7 @@ class UserList extends Component {
if (event.keyCode === KEY_CODES.ARROW_UP) {
this.focusedItemIndex -= 1;
if (this.focusedItemIndex <= -1) {
if (this.focusedItemIndex < 0) {
this.focusedItemIndex = numberOfItems - 1;
}