Fix up/down at the end of the list when the list has less than 10 emotes

This commit is contained in:
Samuel Elliott 2018-04-04 20:34:54 +01:00
parent bbd12a0381
commit a7aa1fa5ec
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
1 changed files with 2 additions and 2 deletions

View File

@ -113,11 +113,11 @@
traverse(e) {
if (!this.open) return;
if (e.key === 'ArrowUp') {
this.selectedIndex = (this.selectedIndex - 1) < 0 ? 9 : this.selectedIndex - 1;
this.selectedIndex = (this.selectedIndex - 1) < 0 ? Math.min(this.emotes.length, 10) - 1 : this.selectedIndex - 1;
return;
}
if (e.key === 'ArrowDown') {
this.selectedIndex = (this.selectedIndex + 1) >= 10 ? 0 : this.selectedIndex + 1;
this.selectedIndex = (this.selectedIndex + 1) >= Math.min(this.emotes.length, 10) ? 0 : this.selectedIndex + 1;
return;
}
return;