Enable skip links on all pages#10839
Enable skip links on all pages#10839colabottles wants to merge 9 commits intoforem:masterfrom colabottles:feature
Conversation
|
Hi @colabottles, I'm closing this as an invalid PR as it's missing a reference issue and lacks a description or context |
|
Reopening as the description and related issue have been supplied. |
There was a problem hiding this comment.
This is looking great @colabottles. I have some comments and a request change. Looking forward to getting this accessibility fix in.
| }) => { | ||
| return ( | ||
| <main class="crayons-layout__content"> | ||
| <main class="crayons-layout__content" id="articles-list"> |
There was a problem hiding this comment.
refactor (blocking): The id fixes in conjunction with converting <div /> to <main /> tags here and all below enable skip links on all the pages where they were not present. The only thing is the id is articles-list which makes sense on the main page, but for other pages it does not.
We could probably go with a more generic id value like skip-link, or something to that effect as it makes it clear what it represents for any page the skip link is on.
There was a problem hiding this comment.
I did articles-list because I wasn't sure on how you wanted to have it re: naming conventions. I can go back in and make the changes if you want to go with skip-link which makes more sense for the inside pages.
There was a problem hiding this comment.
I think main-content would make a lot of sense!
|
I've restarted the buidl, but it looks like these may be valid failures in the build @colabottles. Not sure if you have access to the build logs, but they're here, https://travis-ci.com/github/forem/forem/builds/195148902. Most, if not all seem to be related to admin page tests failing in RSpec. Here's an example: 1) /admin/badges behaves like an InternalPolicy dependant request when user is a single_resource_admin responds with 200 OK
Failure/Error: Unable to find matching line in /home/travis/build/forem/forem/app/views/layouts/admin.html.erb
ActionView::SyntaxErrorInTemplate:
Encountered a syntax error while rendering template: check <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%# The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags %>
<meta name="description" content="">
<meta name="author" content="">
<%= csrf_meta_tags %>
<%= favicon_link_tag SiteConfig.favicon_url %>
<title><%= controller_name.titleize %></title>
<!-- StimulusJS -->
<%= javascript_packs_with_chunks_tag "admin", defer: true %>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<!-- Bootstrap and FontAwesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.16/css/bootstrap-select.min.css" integrity="sha256-g19F2KOr/H58l6XdI/rhCdEK3NmB8OILHwP/QYBQ8M4=" crossorigin="anonymous" />
<%= stylesheet_link_tag "admin" %>
</head>
<body class="admin default-header"
data-honeybadger-key="<%= ApplicationConfig["HONEYBADGER_JS_API_KEY"] %>"
data-release-footprint="<%= ApplicationConfig["RELEASE_FOOTPRINT"] %>"
data-ga-tracking="<%= SiteConfig.ga_tracking_id %>">
<header class="crayons-header" role="banner">
<div class="crayons-header__container">
<%= render "layouts/logo" %>
<h1 class="pl-4 fs-l">
<% if controller_name == "admin_portals" %>
Admin
<% else %>
<a href="/admin">Admin</a>
<span class="color-base-40">»</span> <span class="fw-bold"><%= controller_name.titleize %></span>
<% end %>
</h1>
<div class="crayons-header__links">
<a href="https://forem.gitbook.io/forem-admin-guide/" class="crayons-btn crayons-btn--ghost-brand hidden mr-2 whitespace-nowrap s:block">
Forem Admin Guide
</a>
<a href="/" class="crayons-btn hidden mr-2 whitespace-nowrap s:block">
Go to <%= community_name %> home page
</a>
</div>
</div>
</header>
<div class="crayons-layout <%= controller_name == "admin_portals" ? "" : "crayons-layout--2-cols" %>">
<% unless controller_name == "admin_portals" %>
<div class="crayons-layout__left-sidebar">
<nav class="hidden m:block">
<%= render "admin/shared/navbar" %>
</nav>
</div>
<main class="crayons-layout__content min-w-0" id="articles-list">
<% flash.each do |type, message| %>
<div class="alert alert-<%= type == "notice" || type == "success" ? "success" : "danger" %>">
<button class="close" data-dismiss="alert" aria-label="Close">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
<%= message %>
</div>
<% end %>
<%= yield %>
</main>
</div>
<!-- Bootstrap Dependencies -->
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.16/js/bootstrap-select.min.js" integrity="sha256-COIM4OdXvo3jkE0/jD/QIEDe3x0jRuqHhOdGTkno3uM=" crossorigin="anonymous"></script>
<%= javascript_include_tag "internal" %>
</body>
</html>
Shared Example Group: "an InternalPolicy dependant request" called from ./spec/requests/admin/badges_spec.rb:18
# ./app/views/layouts/admin.html.erb:88: syntax error, unexpected end-of-input, expecting `end'
# ./app/views/layouts/admin.html.erb:88: syntax error, unexpected end-of-input, expecting `end'
# ./app/lib/middleware/time_zone_setter.rb:10:in `call'
# ./app/middlewares/set_cookie_domain.rb:13:in `call'
# ./spec/requests/admin/badges_spec.rb:19:in `block (3 levels) in <top (required)>'
# ./spec/requests/shared_examples/internal_policy_dependant_request.rb:12:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:135:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:135:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# SyntaxError:
# /home/travis/build/forem/forem/app/views/layouts/admin.html.erb:88: syntax error, unexpected end-of-input, expecting `end'
# ./app/views/layouts/admin.html.erb:88: syntax error, unexpected end-of-input, expecting `end' |
|
Thanks so much for this work @colabottles! I'm going to take this for a spin locally. The only thing left is naming the |
|
Hmm, there appears to be an error in some SASS when building Storybook. Could be the things I just committed, giving it a look. https://app.netlify.com/sites/storybookdevto/deploys/5fa569d62163b30007b3ddf8 10:26:52 AM: ERR! Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
10:26:52 AM: ERR! SassError: Invalid CSS after " }": expected selector or at-rule, was "}"
10:26:52 AM: ERR! on line 138 of app/assets/stylesheets/components/header.scss
10:26:52 AM: ERR! from line 20 of app/assets/stylesheets/crayons.scss
10:26:52 AM: ERR! >> }
10:26:52 AM: ERR!
10:26:52 AM: ERR! ---^
10:26:52 AM: ERR!
10:26:52 AM: ERR! SassError: SassError: Invalid CSS after " }": expected selector or at-rule, was "}"
10:26:52 AM: ERR! on line 138 of app/assets/stylesheets/components/header.scss
10:26:52 AM: ERR! from line 20 of app/assets/stylesheets/crayons.scss
10:26:52 AM: ERR! >> }
10:26:52 AM: ERR!
10:26:52 AM: ERR! ---^ |
|
One comment about focus styles, since I saw a commit about "Removed outline on skip link as the opacity change on focus is the visual cue": the focus style needs to meet contrast requirements to replace the default one. There are a lot of faint/subtle interaction styles around the site, so I wanted to give a heads up! |
|
Going to work on getting the specs fixed for this. |
|
As mentioned previously too, the ID will go from The old ID is used in JS, so I need to ensure the places it was used still works. |
|
@nickytonline if that's possible in the context of this refactoring, it'd be great to use a |
You could go with the The issue about the ID is more related to ensuring all the places where it was used in JS as a selector get adjusted. In a lot of cases it's not used because the main landmarks originally had no ID. |
|
@nickytonline you're totally right, that would be a bad idea indeed to have |
|
I tested this out locally, and found some routes that still needed a main element with matching id:
Love seeing this come together, though! it will be really helpful for keyboard access. |
Don't know if you have time to do those extra |
Unfortunately I don't have any free time today or next week @nickytonline unfortunately. Super busy pushing projects out by EOY and the talk I'm giving Saturday. Any time I can help as best I can otherwise though, just give me a shout! |
| <%= render "admin/shared/navbar" %> | ||
| </nav> | ||
| </div> | ||
| <% end %> |
There was a problem hiding this comment.
| <% end %> | |
| <% end %> |
|
Hey @colabottles! 👋🏾 |
|
I spoke with Todd on Twitter DMs and he's got other things to focus on at the moment, so I'm going to add this to @forem/frontend work. |
|
Closing this PR for the time being - thank you @colabottles - as @nickytonline mentioned above we're absorbing this work into our frontend team where we'll build upon your changes here in small increments 👍 Thanks again for this contribution - it's going to be a really positive change for the accessibility of Forems! |
What type of PR is this? (check all applicable)
Description
Adds IDs to all
<main>sections for skip-to-content links to work as intended for keyboard navigation.Related Tickets & Documents
A11y: provide content skip links for keyboard/screen reader users #1153
"Skip Navigation" Links
QA Instructions, Screenshots, Recordings
Please replace this line with instructions on how to test your changes, as well
as any relevant images for UI changes.
Added tests?
Added to documentation?
[optional] Are there any post deployment tasks we need to perform?
[optional] What gif best describes this PR or how it makes you feel?