-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
AC-179 fixing skip links #9909
AC-179 fixing skip links #9909
Conversation
I think there should be a JS or bok_choy test to confirm that this behavior now works as expected, so that things won't break again in the future. |
@clytwynec what would be the best way to test this change? Could this be handled by the new a11y suite? |
@clrux @dan-f This behavior is most likely due to a known bug in Webkit (we've been talking about this in accessibility circles for years and it has to do with the way Apple interpreted the HTML5 spec. They recently acknowledged that its most likely not the correct way to interpret it and have a fix planned, but not implemented: You can find out about a few elegant solutions here: |
6ccc5de
to
a8a07ce
Compare
@cptvitamin and I were talking about this PR. Would the better, more general solution be to change line 139 of main.html to add tabindex="-1" to the div with id="content" (and I imagine main_django.html should also be updated)? |
Thanks @cahrens. I've updated this branch as requested. Do you think it's wise to write tests in this branch, or work with @clytwynec to get something included in her overall accessibility test efforts? |
skip_to = self.q(css=".nav-skip").attrs('href')[0] | ||
self.q(css=".nav-skip").first().click() | ||
return EmptyPromise( | ||
lambda: self.q(skip_to).present, "Main content area received focus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is testing focus. Isn't it just checking that the CSS is present on the page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this, but I think you should be able to just check for self.q("{}:focus".format(skip_to)).present
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may also want to use self.wait_for instead of EmptyPromise
. They both have the same result, but wait_for
is a bit more clear.
I think that tests should be part of this PR (and it looks like you have started them, though I'm not sure the test is doing what you think it is). I'd suggest you and @clytwynec decide together what the appropriate amount of testing should be. |
@@ -107,13 +107,13 @@ | |||
% if not disable_window_wrap: | |||
<div class="window-wrap" dir="${static.dir_rtl()}"> | |||
% endif | |||
<a class="nav-skip" href="<%block name="nav_skip">#content</%block>">${_("Skip to main content")}</a> | |||
<a class="nav-skip" href="#content">${_("Skip to main content")}</a> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cahrens I'm removing the dynamic construction of this, which guarantees it syncs up with the skip link. Is this okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what was there before. You should check with the person who wrote that line of code, if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like Dave St.Germain was the original author of this line and he is no longer with us. My guess is that he was generating these href
's dynamically, which was causing the skip links to only work on some pages. My change makes this reference static so it will nearly always match up with the content area.
cf1c901
to
44a9871
Compare
Turns out it's not as simple as removing the Django dynamic stuff. It seems as if each different template defines the skip link and main content area. We'd need to do a more thorough overhaul to make them all the same, but we'd need to know what else this impacts. For now, I'm just renaming the main template from |
814b787
to
15024a2
Compare
c61d570
to
3e9eee9
Compare
7c7983c
to
8b640cf
Compare
@clytwynec After the break, mind if we connect on this? For some reason, focus isn't being sent to the container in the test, though it works outside of the test. IDs match and I'm using the same keystrokes. It's weird. |
66469d1
to
d435da3
Compare
@@ -462,7 +462,6 @@ def test_account_settings_a11y(self): | |||
self.account_settings_page.a11y_audit.config.set_rules({ | |||
'ignore': [ | |||
'link-href', # TODO: AC-233, AC-238 | |||
'skip-link', # TODO: AC-179 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clrux Removing these 'skip-link' lines will result in a check for the skip link on the page during the test, so this should provide the test coverage needed.
0f0417d
to
4baeba2
Compare
@clytwynec There's a single failing a11y test. When stepping through, the skip link has a matching |
@clrux Is the link target focusable on the failing page? |
@clytwynec It is in the test browser that pops up. It has a matching |
@clrux Is the tabindex on the |
@clytwynec Whew, got it. Thanks for the tips. Can you verify this is okay? |
@@ -267,6 +267,7 @@ def test_cohorted_search_user_staff_all_content(self): | |||
self._goto_staff_page().set_staff_view_mode('Staff') | |||
self.courseware_search_page.search_for_term(self.visible_to_all_html) | |||
assert self.visible_to_all_html in self.courseware_search_page.search_results.html[0] | |||
# from nose.tools import set_trace; set_trace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks!
@clrux I can help verify if you have a sandbox for me. Also, what's up with |
@dan-f Sandbox is up: https://clrux-ac-179.sandbox.edx.org/ As for the legacy dashboard, just realized that it was re-added in this work. Sarina removed it on 10 Dec. I'll remove it along with the commented test line. |
@clrux behaviorally, it's working for me in Chrome and Firefox. Safari is another story - I can't seem to focus on anything, though this has happened to me before and I think it may be safari's fault or my fault in not setting it up properly. Would you be able to verify Safari? The skip link is getting rendered oddly when it has focus within the actual course. Here's a screenshot. Check out the upper left corner. |
@dan-f I'm updating the sandbox. Safari bug should be fixed. Thanks for the catch! |
LGTM 👍 great work! One minor nitpick is that I'm not seeing focus rendered on the "Skip to main content" element. Not sure if that's an issue or not, but I wanted to raise it. Also - I figured out how to fix/enable tabbing in Safari. Here's the link: http://osxdaily.com/2011/08/14/enable-tab-key-navigation-safari/ |
@dan-f Thanks man. I noticed the lack of the outline too, but it's inconsistent, and I think it's related to styles. I wasn't going to worry about it since I originally thought that styles was out of scope. But, it does deal with skip links so I'm inclined to try and track down where the overrides are coming from. |
3655775
to
41effd5
Compare
@dan-f I've forced the outline. Please verify at your convenience. |
Nice. I'm not seeing the outline - did you update the sandbox? I won't nitpick here - you have a 👍 from me, and I trust that you'll get the outline. Let me know if you want me to help verify though! |
👍 |
@dan-f I'll squash and update the sandy if for nothing more than accountability. |
d1f91f9
to
c2b1d03
Compare
c2b1d03
to
2a4e141
Compare
@dan-f Sandbox is ready. I did a quick run-through and found one miss. The discussion forums focusable container didn't have a |
This piece of work addresses the skip links in the LMS and relates to AC-179.
Background
The skip link is a page anchor to the main content area. While the page would jump to the target container, focus wouldn't be sent correctly in all cases. The container wasn't set to receive focus (i.e.,
tabindex="-1"
) so focus wouldn't be sent. Firefox interpreted the skip link and sent focus, but this behavior is abnormal.Solution
I did three things, one of which addresses the issue, the other two are extracurricular. I...
section role="main"
to amain
elementtabindex="-1"
to this container, andSandbox
https://clrux-ac-179.sandbox.edx.org
Reviewers
cc @cptvitamin @cahrens