Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make search result elements keyboard focusable #259

Closed
wants to merge 2 commits into from

Conversation

jakeisnt
Copy link

@jakeisnt jakeisnt commented Jan 1, 2021

Closes #258

  • Replaced <tr/> element with <a/>
  • Styled <a/> like <tr/>

This may not be a comprehensive fix, but it works well with Vimium.
If there are any style conventions I should follow please let me know!

@jakeisnt
Copy link
Author

jakeisnt commented Jan 1, 2021

I realized I'd only added this fix to Packages; just added it to Options as well. This PR is ready now.

@garbas garbas self-requested a review January 5, 2021 12:21
Copy link
Member

@garbas garbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakeisnt thank you for taking the time to fix this.

The HTML you are producing is not correct, since you can only have td inside tr. I think we would need to move away from table anyway and use CSS Grid.

Also please put the styles into src/index.less.

@turboMaCk
Copy link
Member

turboMaCk commented Jan 5, 2021

I did not tried it but I think the simplest solution would be to just add tabindex attribute to tr element (which has onClick handler) to make it focusable by tab. If this works we avoid any changes in HTML and CSS to get this functionality. On the other hand using a element provides additional semantics which are good for accessibility.

My understanding is that while there is an agreement that the issue should be addressed, the majority feels it should be addressed together with planed redesign and that it's not important to roll out quick-fix soon. But perhaps if enough people feel like this should be fixed ASAP we can discuss quick fix independent of a redesign.

@jakeisnt
Copy link
Author

jakeisnt commented Jan 5, 2021

Did you try the changes out? display: table-row causes the <a/> tag to display like a <tr/> tag, so this is perfectly fine. With this change the website appears identical to how it did before.

I'm not sure what you mean by 'not correct' but this is definitely a valid solution to the issue.

I agree that inline styles aren't the best practice - I cam move those.

@samueldr mentioned in the issue I opened that an html tag should be used rather than tabindex as the browser already defines behavior for interacting with HTML tags and tabindex can be finicky.

@samueldr
Copy link
Member

samueldr commented Jan 5, 2021

My suggestion wrapped the first cell's content:

(Here it's a button, but an <a>nchor can also be used if we have a real href to point it to)

The main drawback with wrapping only the first element with a link is that the "whole row" won't be selected by keyboard navigation, but that's not really an issue.

@turboMaCk
Copy link
Member

turboMaCk commented Jan 5, 2021

I'm not sure what you mean by 'not correct'

It's indeed not correct semantically. It is correct in terms of display/render but there are other ways in which HTML/DOM structure can be incorrect which can lead to problems other than rendering in browser.

an html tag should be used rather than tabindex as the browser already defines behavior for interacting with HTML tags and tabindex can be finicky

I've seen @samueldr 's comment I think he is right just for a different reason than that the bahaviour of tabindex is unreliable in some way. I agree that using a is more correct in terms of semantics. Semantics matter for things like accessibility (screen reader assistant software etc.). I believe what he argues for is that there are other things to improve beyond just allowing tab navigation. These are related to each other and that it would make sense to consider them together. Click actions on unexpected elements can simply make it impossible for some types of software to assist user effectively and should be avoided. @samueldr can you maybe clarify if we're on the same page?

I agree with both @garbas and @samueldr. However in my opinion the best quick fix route would be tabindex since that doesn't make situation around semantics much worse and is simple. With redesign though we should avoid click and tabindex on tr in favor of element like <a> or <button> which are expected to have click actions.

@turboMaCk
Copy link
Member

@samueldr actually regarding:

The main drawback with wrapping only the first element with a link is that the "whole row" won't be selected by keyboard navigation, but that's not really an issue.

What if we would do exactly that and just remove the "only". We can keep both button as well as event handler on <tr>. That way tab:

  • for mouse users we would keep convenience of having whole row clickable
  • tab selection would simply work via buttons
  • to meet the accessibility standard we would have button as well (an element that is expected to have action on click).

turboMaCk added a commit that referenced this pull request Jan 5, 2021
- improves usability with keyboard #258
- improves accessbility

See #259 for other relevant discussion
@samueldr
Copy link
Member

samueldr commented Jan 5, 2021

What if we would do exactly that and just remove the "only". We can keep both button as well as event handler on . That way tab

To remove the "only", three scenarios:

  • wrap the whole <tr> → broken HTML.
  • stop using a <table> → need to re-implement styles (possible with upcoming redesign).
  • add as many <button> as columns → need to tab through the whole row before going to the next.

But, uh, now that I look at your solution, what you implemented is what I had in mind, and I see the miscommunication. I didn't intend to make only the first cell clickable, I was only thinking about adding one focusable element per row.

garbas added a commit that referenced this pull request Jan 6, 2021
- improves usability with keyboard #258
- improves accessbility

See #259 for other relevant discussion

Co-authored-by: Rok Garbas <rok@garbas.si>
@garbas
Copy link
Member

garbas commented Jan 6, 2021

This has been solved in #260. @jakeisnt thank you for bringing this issue up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search result elements should be keyboard focusable
4 participants