Improve account modal keyboard navigation (#424)

* Add back button support to account keyboard navigation and autofocus text input on the form

* Wrap modal content with keyboard navigation controller
This commit is contained in:
Sergey Tyan
2024-02-12 03:17:03 +08:00
committed by GitHub
parent fbe49bf4ea
commit e79ff94f6c
2 changed files with 10 additions and 7 deletions

View File

@@ -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) {