Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

a11y: remove tabindex and allow escaping codemirror #168

Closed
wants to merge 1 commit into from

Conversation

geoffrich
Copy link
Member

Fixes #163

This PR makes some accessibility improvements to the REPL:

  • Remove the positive tabindex on the text area. This was causing the REPL to be the first thing focused on the page. This impacted the svelte.dev homepage, since a keyboard user would skip the initial page content and immediately enter the first REPL example when they pressed Tab on initial load (see also https://github.com/sveltejs/svelte/issues/6369). I didn't notice anything broken by removing the tabindex, but let me know if I missed anything.
  • Allow escaping the CodeMirror by pressing Esc. If a keyboard-only user entered the REPL, they could not get out since pressing Tab triggered indentation. Now, if they hit Esc, the next press of Tab or Shift-Tab will use the default browser tabbing behavior. Otherwise, Tab will be used for indentation. CodeMirror 6 will have a similar escape hatch. I wasn't sure how/if to document this, but it's there if people need it.
  • Use visibility: hidden to hide the output JS and CSS panels. Otherwise, they were receiving focus even when their corresponding tab was not selected. This caused focus to be lost when navigating with the keyboard. There was a 2-year-old comment saying that visibility couldn't be used due to a Chrome bug, but I didn't notice any weird behavior after applying my change. Maybe that bug isn't an issue in the latest Chrome? Let me know if I should find another way to approach the problem.

I linked my local REPL with my local svelte.dev to test the changes and verified that keyboard navigation works as expected.

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

Looks good to me. @pngwn might know more about the history of the visibility bug and why tabindex was positive. Only thing I can think of is that it should be focused directly when going to the repl page? Is that the case currently? If so, and if this is desirable for that page, it could become a prop.

@geoffrich
Copy link
Member Author

I don't think having the positive tabindex is desirable on the REPL page either since it makes for a confusing tab order, though maybe someone has a different perspective. See also the reasons outlined by the Axe a11y tool.

Thanks for the review!

@Rich-Harris
Copy link
Member

thank you! closing in favour of sveltejs/sites#122

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

Successfully merging this pull request may close these issues.

svelte-repl component breaks site keyboard navigation
3 participants