From ed50061402fda90206479820b515a4a57636b080 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 18 Feb 2026 18:41:31 +0000 Subject: [PATCH] Avoid using positive tabindexes The use of positive tabindexes is widely discouraged. Instead, we should order the elements of the page in the same order as they are displayed, which they are already. Previously the tab indexes did match the order that these elements were shown on the page, but the lack of tabindexes on certain other elements was used to "skip over" things like explanatory links in forms. This made these other elements hard to focus, and meant that overall the focus skipped around the page unintuitively. It is less confusing for keyboard users if the focus just moves around in the same order that the elements are shown on the page, which is also the same order they appear in the html. See https://herb-tools.dev/linter/rules/html-no-positive-tab-index and the list of references on that page, for further discussion. --- app/views/layouts/map.html.erb | 2 +- app/views/sessions/new.html.erb | 8 ++++---- app/views/users/new.html.erb | 11 +++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/views/layouts/map.html.erb b/app/views/layouts/map.html.erb index 3b61b6318..e9045633a 100644 --- a/app/views/layouts/map.html.erb +++ b/app/views/layouts/map.html.erb @@ -63,7 +63,7 @@ <%= render :partial => "layouts/sidebar_close" %> -
<%# herb:disable html-no-positive-tab-index %> +
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index d5f5d2c55..5346e0cdb 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -46,21 +46,21 @@ <%= bootstrap_form_tag(:action => "login", :html => { :id => "login_form" }) do |f| %> <%= hidden_field_tag("referer", h(params[:referer]), :autocomplete => "off") %> - <%= f.text_field :username, :label => t(".email or username"), :autofocus => true, :tabindex => 1, :value => params[:username] %> + <%= f.text_field :username, :label => t(".email or username"), :autofocus => true, :value => params[:username] %>
<%= f.label :password, t(".password") %> <%= link_to(t(".lost password link"), user_forgot_password_path) %>
- <%= f.password_field :password, :autocomplete => "on", :tabindex => 2, :value => "", :skip_label => true %> + <%= f.password_field :password, :autocomplete => "on", :value => "", :skip_label => true %> <%= f.form_group do %> - <%= f.check_box :remember_me, { :label => t(".remember"), :tabindex => 3, :checked => (params[:remember_me] == "true") }, "yes" %> + <%= f.check_box :remember_me, { :label => t(".remember"), :checked => (params[:remember_me] == "true") }, "yes" %> <% end %>
- <%= f.primary t(".login_button"), :tabindex => 4 %> + <%= f.primary t(".login_button") %>
<% end %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index a53fdbc83..824316151 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -48,21 +48,20 @@ t(".email_help.privacy_policy_url"), :title => t(".email_help.privacy_policy_title"), :target => :new)), - :autofocus => true, - :tabindex => 1 %> + :autofocus => true %> <% else %> <%= f.hidden_field :email %> <% end %> - <%= f.text_field :display_name, :help => t(".display name description"), :tabindex => 2 %> + <%= f.text_field :display_name, :help => t(".display name description") %> <% if current_user.auth_uid.nil? %>
- <%= f.password_field :pass_crypt, :tabindex => 3 %> + <%= f.password_field :pass_crypt %>
- <%= f.password_field :pass_crypt_confirmation, :tabindex => 4 %> + <%= f.password_field :pass_crypt_confirmation %>
<% end %> @@ -80,7 +79,7 @@ :target => :new)) %>

- <%= submit_tag(t(".continue"), :name => "continue", :id => "continue", :class => "btn btn-primary", :tabindex => 5) %> + <%= submit_tag(t(".continue"), :name => "continue", :id => "continue", :class => "btn btn-primary") %>
<% end %> -- 2.39.5