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

docs a11y: wrap code blocks instead of overflowing #5718

Closed
wants to merge 1 commit into from

Conversation

geoffrich
Copy link
Member

This PR resolves one of the Axe accessibility violations in #5678: Ensure that scrollable region has keyboard access (74 count).

The code blocks were set to overflow: auto so that they would horizontally scroll when the content became too long. However, this had accessibility issues because keyboard-only users had no way to scroll the code blocks and would be unable to see part of the examples.

One way to fix this would be to add tabindex="0" to all code blocks to allow them to be focused and scrolled. However, this would make all 200+ code blocks in the documentation tab stops, even when they don't overflow. This could make it more tedious to navigate the docs using the keyboard. In addition, focusable elements must have an accessible name, which the code blocks do not have.

Because of these issues, I instead chose to force the code blocks to wrap instead of overflowing. This doesn't affect many code blocks when viewing the docs on a desktop, because the screen is wide enough to fit most lines. The code blocks wrap more aggressively on mobile, but they are still readable. IMO, this is an acceptable trade-off to make sure the docs are accessible to as many people as possible.

Example wrapping on desktop:
image

Example wrapping on mobile:
image

@stale
Copy link

stale bot commented Jun 26, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Jun 26, 2021
@geoffrich
Copy link
Member Author

I'll go ahead and close this since svelte.dev will be migrating to SvelteKit soon. If still relevant, I'll re-create the PR in the sites repo.

@geoffrich geoffrich closed this Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants