I'm updating some old code to be ADA compliant and need to give each <li>
in the nav tabindex="0"
so they are all accessible via keyboard.
This is the code that generates the navigation <li>
s. It wasn't written by me and I only knew what Arbre was because a senior dev pointed it out but neither of us are sure how to add the tabindex.
def nav_item_column_list(nav_item, row_number, column_number)
sub_item = nav_item.children.where(column_number: column_number).all[row_number]
if sub_item.present?
Arbre::Context.new({:helper => self}) do
ul do
li do
a sub_item.title, href: sub_item.url
if sub_item.children.count > 0
ul do
sub_item.children.each do |child|
li do
a child.title, href: child.url
end
end
end
end
end
end
end
end
end
While the documentation is compact, it says
So I would guess you could write something like
So I tested this: