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

Restructure single template to follow a better DOM structure for A11Y #58

Closed

Conversation

alexstine
Copy link
Contributor

The largest change places the sidebar after the closing </main> for better ARIA landmark support/DOM structure for accessibility. Many visual regressions will be caused by this PR, hoping Meta Team can help out with CSS adjustments.

Screenshots

Before After
image image

How to test the changes in this Pull Request:

  1. Open a single doc article.
  2. Notice the sidebar is moved.
  3. Notice meta information appears just below the main heading 1/article title.

@ryelle
Copy link
Collaborator

ryelle commented Apr 6, 2023

The table of contents sidebar actually stays in the right place, visually, so that's good 🙂

I don't think we want to move the meta to the top of the article, that was put at the end intentionally in the design. Same with flipping the search box below the "In this article" section. If you can update this to simply move the aside group, though, we can probably get that merged fairly quickly.

@ryelle
Copy link
Collaborator

ryelle commented Apr 6, 2023

Actually, I just remembered why the markup was done this way— on small screens, the table of contents should appear between the heading & the content.

@WordPress/meta-design What do you think of flipping the content & ToC on small screens? It would look roughly like this:

top of article, heading then content

bottom of article, with table of contents right after comment form

@alexstine Could you also explain why these improvements are better for accessibility?

@alexstine
Copy link
Contributor Author

@ryelle

I don't think we want to move the meta to the top of the article, that was put at the end intentionally in the design.

This info is not really discoverable where it currently sits. Just underneath the article title would be a big improvement.

Could you also explain why these improvements are better for accessibility?

This is better because of how ARIA landmarks currently work in screen readers. Picture this HTML structure.

<main>
<aside></aside>
</main>
<footer></footer>

When a screen reader user jumps by landmarks, it helps them find important sections of the page. My example above uses HTML5 tags just like the docs site does. The HTML5 specification as shown above maps to the following ARIA roles: main, complementary, and contentinfo. Anyway, back to the point. In the current state of things, If I navigate by landmark, I will get main content, then the sidebar, then the footer. This is why it is always better to leave the aside outside of the main. Having nested landmarks does not improve the navigation experience.

Does this make sense? Can record a quick video if not. Before and after.

Thanks.

@ryelle ryelle added [Status] Needs Design Feedback [Component] Theme Templates, patterns, CSS Accessibility Issues related to keyboard navigation, screen readers, etc labels Apr 7, 2023
@jasmussen
Copy link

Definitely one we need to solve. Thinking through the flow, I do wonder how useful the table of contents will be for someone browsing on a mobile device, if it sits at the end. My instinct would be that on mobile, it should sit at the top mainly so that you can jump to sections without having to swipe a lot.

Would it be feasible to find a design that let it sit at the top, but in a collapsed manner? Perhaps not a details/summary combo, but something like it?

@alexstine
Copy link
Contributor Author

@jasmussen I agree. Having the table of contents collapsed below the main heading would be a suitable solution. I just really do not want the presentation of a sidebar in the main content.

@ryelle Is the table of contents block specific to this site or is this going to require a global change .org wide?

@ryelle
Copy link
Collaborator

ryelle commented Apr 10, 2023

Having the table of contents collapsed below the main heading would be a suitable solution. I just really do not want the presentation of a sidebar in the main content.

Would the solution be to not use the aside wrapper if we collapse it?

Is the table of contents block specific to this site or is this going to require a global change .org wide?

The block itself is site-wide (in the wporg-mu-plugins repo). It's currently only used on this site, but it's been suggested that it would be useful on other sites as we roll out the redesign. Hopefully if we land on a good page structure here, we can reuse that layout for other sites as well.

@alexstine
Copy link
Contributor Author

@ryelle

Would the solution be to not use the aside wrapper if we collapse it?

Correct.

Okay, let me go figure out how this block currently works and see if I can make an easy PR for it.

Thanks.

@adamwoodnz
Copy link
Contributor

Worth noting that it is not usually that complicated to reorder content visually (using flex or grid) as long as the HTML structure is fairly flat. Sounds like we're looking to remove nesting which is helpful.

@alexstine alexstine marked this pull request as ready for review April 11, 2023 03:19
@alexstine
Copy link
Contributor Author

@ryelle @jasmussen Moved the table of contents out of the sidebar and below the document meta. This will not be really testable as this is now a dependency on the upstream plugin. Hopefully this gives some idea as to how it may look visually.

@fcoveram
Copy link

fcoveram commented Apr 20, 2023

Here is an idea that taps into what @jasmussen suggested

Mobile

Four mockups of WordPress pages on mobile, the two on the left show the non-focus version whereas the two on the right show the focus version

Desktop

A mockup showing the first section of a WordPress page. Heading 1 and Table of Content are visible

In both desktop and mobile the text style of TOC heading and anchor links are the same, and ul has a different padding to be aligned with the heading. On mobile, padding values are different to reach a visual balance with the expand / collapse action.

Guide and CSS notes for the Table of Content component on desktop and mobile


What do you think of this idea?

@ryelle
Copy link
Collaborator

ryelle commented May 8, 2023

In #63, the sidebar container was updated and now uses a plain div. It's still right after the article heading, but at least it's not an aside anymore. That's been merged, so you can try it, for example on Introduction to Blogging.

The ability to expand/collapse the table of contents is being discussed in WordPress/wporg-mu-plugins#389.

With that, I'm going to close this PR, as the two links above should cover everything. If I missed something let me know & we can re-open or open a new issue as needed.

@ryelle ryelle closed this May 8, 2023
@alexstine
Copy link
Contributor Author

I still wonder if "Search documentation" form can be moved to somewhere else. Maybe make it apart of the banner landmark just after the main navigation? Having search documentation form after the main document title does not make much sense. I agree this related change removing the complementary landmark was good.

@ryelle
Copy link
Collaborator

ryelle commented May 10, 2023

Visually, the search form is part of the sidebar, so we can't move it without changing the page layout somehow… so that's a question for @WordPress/meta-design.

Maybe make it apart of the banner landmark just after the main navigation?

Is that the global header (the part that's the same on all sites)? There's already the global site search, which searches all of wordpress.org, in that section (it is confusing that there are two search forms, but this one that's currently in the sidebar/after the header searches just the documentation site).

@alexstine
Copy link
Contributor Author

It would be nice if the search form for docs could be in the sidebar, it makes sense there but will look odd if that is the only thing in the sidebar. Placed after the main title does not make any sense unfortunately. It may visually but this would not appear where screen readers would expect. Any chance that global search in the future can be improved to have a combo box? E.g. search whole site, search docs, search X, etc?

@StevenDufresne
Copy link
Contributor

Any chance that global search in the future can be improved to have a combo box? E.g. search whole site, search docs, search X, etc?

This idea is somewhat relevant to the discussion about suggesting terms in the dropdown: WordPress/wporg-mu-plugins#367.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility Issues related to keyboard navigation, screen readers, etc [Component] Theme Templates, patterns, CSS [Status] Needs Design Feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants