Improve account modal keyboard navigation #424
Reference in New Issue
Block a user
Delete Branch "feature/account-hotkey-navigation-improvement"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add back button support to account keyboard navigation and autofocus text input on the form
demo video:
It would probably be better to move the controller further up the DOM so that the back link is included in the scope for the query for focusable links instead of changing the javascript controller to handle this edge condition of there being a back link.
Perhaps on the entire modal, or something?
@@ -20,1 +20,3 @@return this.focusableLinks[indexOfLastFocus + direction]let nextIndex = (indexOfLastFocus + direction) % this.focusableLinks.lengthif (nextIndex < 0) nextIndex = this.focusableLinks.length - 1if last item is focused and you press "down" then next focus will go to the first item
hey @JoshAntBrown, I added an optional attribute for passing
data-controllerto the modal, please take a look@@ -1,12 +1,12 @@<h1 class="text-3xl font-semibold font-display"><%= t('.title')%></h1>We should update the modal helper to accept the args, and directly rather than bringing it's complexity into our view.
The modal helper is just a function at the end of the day so can accept any args we want:
That said, if we take this approach, I also feel like it should accept args as if it were any regular tag builder helper. This would add a fair amount of complexity to the helper as we would need to figure out how to merge it's base properties and attributes with those we pass in here.
I think we can take an even simpler approach and just render a div inside the modal that wraps all the content and applies our list-keyboard-navigation controller.
@@ -20,1 +20,3 @@return this.focusableLinks[indexOfLastFocus + direction]let nextIndex = (indexOfLastFocus + direction) % this.focusableLinks.lengthif (nextIndex < 0) nextIndex = this.focusableLinks.length - 1Sounds good! Nice improvement.
@@ -1,12 +1,12 @@<h1 class="text-3xl font-semibold font-display"><%= t('.title')%></h1>sure, will update the pr, thanks for the feedback!
@@ -1,12 +1,12 @@<h1 class="text-3xl font-semibold font-display"><%= t('.title')%></h1>@JoshAntBrown updated, please take a look
Great job on this, @sergey-tyan!
thank you @Shpigford!