Skip to content

Commit ae6334f

Browse files
committed
Fix bug where we would not check if there was actually a page to navigate to when using arrow keys
1 parent 98cd2f0 commit ae6334f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/theme/book.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ $( document ).ready(function() {
3232
switch (e.keyCode) {
3333
case KEY_CODES.NEXT_KEY:
3434
e.preventDefault();
35-
window.location.href = $('.nav-chapters.next').attr('href');
35+
if($('.nav-chapters.next').length) {
36+
window.location.href = $('.nav-chapters.next').attr('href');
37+
}
3638
break;
3739
case KEY_CODES.PREVIOUS_KEY:
3840
e.preventDefault();
39-
window.location.href = $('.nav-chapters.previous').attr('href');
41+
if($('.nav-chapters.previous').length) {
42+
window.location.href = $('.nav-chapters.previous').attr('href');
43+
}
4044
break;
4145
}
4246
});

0 commit comments

Comments
 (0)