diff --git a/app/javascript/controllers/list_keyboard_navigation_controller.js b/app/javascript/controllers/list_keyboard_navigation_controller.js index 9a019e86..7e28069e 100644 --- a/app/javascript/controllers/list_keyboard_navigation_controller.js +++ b/app/javascript/controllers/list_keyboard_navigation_controller.js @@ -17,7 +17,10 @@ export default class extends Controller { getLinkTargetInDirection(direction) { const indexOfLastFocus = this.indexOfLastFocus() - return this.focusableLinks[indexOfLastFocus + direction] + let nextIndex = (indexOfLastFocus + direction) % this.focusableLinks.length + if (nextIndex < 0) nextIndex = this.focusableLinks.length - 1 + + return this.focusableLinks[nextIndex] } indexOfLastFocus(targets = this.focusableLinks) { diff --git a/app/views/accounts/new.html.erb b/app/views/accounts/new.html.erb index b8a2d4c1..9fe5f3fe 100644 --- a/app/views/accounts/new.html.erb +++ b/app/views/accounts/new.html.erb @@ -1,12 +1,12 @@