-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Support external navigation links #876
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
Support external navigation links #876
Conversation
mattxwang
left a comment
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.
Hi @SPGoding, thanks for the contribution - appreciate you taking this up.
I have two small requests:
- Some in-code comments (tagged)
- The icon seems a bit off-center; I'm on macOS with Chrome, and I see something like this:
Could you shift the icon down a little bit with CSS, and/or align the bottom with the font line?
Let me know what you think!
_includes/nav.html
Outdated
| <li class="nav-list-item external"> | ||
| <a href="{{ node.url | absolute_url }}" class="nav-list-link external"> | ||
| {{ node.title }} | ||
| {% unless node.hide_icon %}<svg viewBox="0 0 24 24"><use xlink:href="#svg-external-link"></use></svg>{% endunless %} |
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.
Since this icon doesn't add any semantic meaning, we should hide it from a screenreader. I think in this case, we want to add
| {% unless node.hide_icon %}<svg viewBox="0 0 24 24"><use xlink:href="#svg-external-link"></use></svg>{% endunless %} | |
| {% unless node.hide_icon %}<svg aria-hidden="true" viewBox="0 0 24 24"><use xlink:href="#svg-external-link"></use></svg>{% endunless %} |
For more, this blog post by CSS Tricks is a good summary.
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.
Nice points about accessibility. Correct me if I'm wrong -- but doesn't this icon convey that this is an external link, thus has semantic meaning?
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 know what - you're completely right, that slipped my mind. Hm, in that case, I think having some screenreader-only/aria text that says "(external link)" would make the most sense.
It seems like there's no consensus on exactly what it should say. If you have a suggestion instead of "(external link)", please go for it instead!
Precedent:
- W3 WCAG20 spec saying that advanced warning is necessary
- deque checklist on links
- WebAIM article
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.
Thanks for the response! The <title> element can also be used to provide a text description, which would be shown as a tooltip on most browsers. I think that tooltip could be beneficial for non-screenreader users as well, so I will instead have <title>(external link)</title> inside the <symbol> definition, and have an aria-labelledby attribute on the <svg> tag to reference that title text.
|
This feature is more complicated than I originally thought >_< If I understand the accessibility standards correctly, there are two types of links we may need to take care of here:
There are several cases I could think of where a user may want to add an external link:
* The "mandatory" should still just be an advice, as users can choose to write something like I'm not sure what's the best way to set up the configuration options to allow users of just-the-docs to configure it according to their needs -- adding three options ( Another issue I see is that we only have one icon that we could use to indicate either "external site" or "opens in new tab", which may be a source of ambiguity. |
|
Really appreciate the thought you've put into this! A bit swamped with work and other personal obligations but I'll be back with a review/more thoughts over the next few days! |
|
Coming back to open PRs now. Thanks again for your detailed report @SPGoding; some thoughts:
What do you think? (testing locally, I think the link alignment is better, and the |
|
Thanks for your feedback! I agree with keeping the scope of this PR small, and I created #881 to keep track the accessibility concerns around links that open in new tabs. |
mattxwang
left a comment
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.
Sounds good. Thanks for your quick response and your contribution @SPGoding! Hopefully this will be released soon!
The navigation should only display the external links once, after the links to pages that are not in collections. The test for PR just-the-docs#876 at https://just-the-docs.github.io/just-the-docs-tests/navigation/external-links fails with v0.4.0.rc3, and succeeds when the updated `nav.html` is added locally. The docs need updating to clarify how the interaction between the collections feature and the external links feature is resolved.
Fix external links and collections The navigation should only display the external links once, after the links to pages that are not in collections. The test for PR #876 at https://just-the-docs.github.io/just-the-docs-tests/navigation/external-links fails with v0.4.0.rc3, and succeeds when the updated `nav.html` is added locally. The docs need updating to clarify how the interaction between the collections feature and the external links feature is resolved.

Based on #238, resolves #66.