Skip to content

Conversation

anurbol
Copy link
Contributor

@anurbol anurbol commented Oct 31, 2022

Previously there was no way to access code boxes by keyboard, and this was a problem for the scrollable ones.
Fixed it by making code lines focusable, so whenever they get focus the wide code block can be scrolled to the right and left by right and left arrow keys.

This might be considered as a hackish workaround, or not so much, but it's the cleanest option I found. It must be said that the code block is rendered by a 3rd party highlighting component, so we are a bit limited in solutions.

References

Related to https://github.com/github/accessibility-audits/issues/2746

@anurbol anurbol temporarily deployed to github-pages October 31, 2022 08:38 Inactive
@anurbol
Copy link
Contributor Author

anurbol commented Nov 2, 2022

Screen Recording (Ubuntu, Chrome):

simplescreenrecorder-2022-11-02_12.17.09.mp4

Also tested in Firefox (Ubuntu), Safari (MacOS)

@anurbol anurbol marked this pull request as ready for review November 2, 2022 06:18
@darcyclarke darcyclarke added the accessibility Issues of PRs related to accessibility improvements label Nov 7, 2022
@anurbol
Copy link
Contributor Author

anurbol commented Nov 14, 2022

Finally fixed the issue on MacOS+Chrome

simplescreenrecorder-2022-11-14_16.19.08.mp4

@anurbol anurbol temporarily deployed to github-pages November 14, 2022 10:28 Inactive
@amit-avit
Copy link

I'm ok with the idea behind the fix but when the new div gets focused the outline looks weird.
image

I would say we fix this as well before we merge this.

@anurbol
Copy link
Contributor Author

anurbol commented Nov 14, 2022

I'm ok with the idea behind the fix but when the new div gets focused the outline looks weird. image

I would say we fix this as well before we merge this.

I made a few experiments, but none of them seems to be nice enough.

  1. We could hide the outline - but then the user would be confused where did the focus go.
  2. We could apply display: block; width: 100%;, but then the outline will be a black wide line, which is also weird, isn't it?

We cannot put the code contents into the div with tabindex, this will cause MacOS' Chrome read the code three times (as it will consider it a "group" - not sure why)

@Seryozha95
Copy link
Contributor

I'm ok with the idea behind the fix but when the new div gets focused the outline looks weird. image
I would say we fix this as well before we merge this.

I made a few experiments, but none of them seems to be nice enough.

  1. We could hide the outline - but then the user would be confused where did the focus go.
  2. We could apply display: block; width: 100%;, but then the outline will be a black wide line, which is also weird, isn't it?

We cannot put the code contents into the div with tabindex, this will cause MacOS' Chrome read the code three times (as it will consider it a "group" - not sure why)

@anurbol visibility: hidden should fix the focus issue.

@anurbol
Copy link
Contributor Author

anurbol commented Nov 15, 2022

Unfortunately no, it prevents it from getting focus at all.

@amit-avit
Copy link

amit-avit commented Nov 15, 2022

Can we try to make this new div have the width and height as the parent container and make use of z-index to move it behind the text elements.
Basically if somehow we can make the focus outline appear to be visible for the entire box will make it better.

@anurbol
Copy link
Contributor Author

anurbol commented Nov 15, 2022

Can we try to make this new div have the width and height as the parent container and make use of z-index to move it behind the text elements

I think this can't be done with CSS alone, but with the help of javascript. So it probably starts looking like an overkill.
Anyway, I'll try

@amit-avit
Copy link

@arisacoba a fix is made to make a text box with horizontal scrollbar to be able to scroll while using keyboard. When the element is focused it looks as below, is it ok to proceed with?
image

@anurbol
Copy link
Contributor Author

anurbol commented Nov 16, 2022

@amit-avit Done here. Tried to make it as simple as possible... still doesn't look very nice

@anurbol anurbol temporarily deployed to github-pages November 16, 2022 14:10 Inactive
Copy link

@amit-avit amit-avit left a comment

Choose a reason for hiding this comment

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

This looks much better even though a bit more complex.
LGTM

BTW you tagged wrong amit in ur comment 😁

@arisacoba
Copy link
Member

@anurbol @amit-avit best to cross-post this concern with #accessibility-design on Slack if we haven't yet. They have the best knowledge of how this can be implemented properly

@anurbol
Copy link
Contributor Author

anurbol commented Nov 17, 2022

@anurbol @amit-avit best to cross-post this concern with #accessibility-design on Slack if we haven't yet. They have the best knowledge of how this can be implemented properly

Fair enough, created a thread https://github.slack.com/archives/C03RM57QL64/p1668668686952059
(I hope though we won't have to redo this stuff 🥲 )

@lindseywild
Copy link

Hi! Trying to review this using the instructions in the README but npm run develop errors out -- do you know if there's an updated way to view this locally, or a staging URL I can review? Thanks!

@20shivangi
Copy link
Contributor

Hi! Trying to review this using the instructions in the README but npm run develop errors out -- do you know if there's an updated way to view this locally, or a staging URL I can review? Thanks!

@lindseywild You can make use of this preview URL : https://npm-f9a17b3f5d-15913497.drafts.github.io/, it has the changes that are made in this PR

@lindseywild
Copy link

Thank you for this! It's a lot better than what is currently there, which doesn't work at all, so I like it! I realize that this isn't entirely elegant due to the constraints of the third-party code. I was able to test this on Chrome with a keyboard, Safari with a keyboard + VoiceOver, and NVDA + Chrome. NVDA reads "blank" when tabbing to the code example, but I'm not sure if that can be easily fixed... It doesn't prevent the user from doing anything, it's just a little odd. To cover our bases, if you could open an issue in the third-party library stating that keyboard functionality doesn't work for scrollable boxes, that'd be great -- that will allow us to close the audit issue even with a few quirks. Thanks!

@Seryozha95 Seryozha95 merged commit c2cfe93 into main Nov 18, 2022
@Seryozha95 Seryozha95 deleted the accessible-scrollable-code-area branch November 18, 2022 12:37
@Spiritaine
Copy link

Awesome thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Issues of PRs related to accessibility improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants