Comments (7)
Alright, pushed a couple of things so all of the above ideas are now possible!
For your last example, these options (pseudocode) should do the trick:
var toString = require('mdast-util-to-string')
var h = require('hastscript')
var options = {
behavior: 'after',
group: h('div'),
content: function (node) {
return [
h('span.visually-hidden', 'Read the "', toString(node), '" section'),
h('span.icon.icon-link', {ariaHidden: true})
]
}
}
from remark-autolink-headings.
Thanks for the reference @wooorm, I was struggling to find good examples in the wild. His approach is also good, as the link and the heading will both be announced.
<div>
<h2 id="what-exactly-is-a-portal" tabindex="-1">What exactly is a portal?</h2>
<a href="#what-exactly-is-a-portal">
<span class="visually-hidden">Read the "What exactly is a portal?" section</span>
<span class="icon icon-link" aria-hidden="true"></span>
</a>
</div>
from remark-autolink-headings.
Heya! I remember a while back we talked about accessibility and weren't totally sure what the preferred method would be, I couldn't find any articles on this then, do you know of any?
Regarding your first solution, that is already an option with the 'wrap' behavior, right?
I'm up for changing the default to wrap, but would still like to make append and prepend accessible as well, any suggestions for those?
from remark-autolink-headings.
I'll look around – I'm not 100% sure that this is covered in spec, but I do know that there is an axe testing rule that catches things like this for the reasons I specified: https://dequeuniversity.com/rules/axe/3.3/aria-hidden-focus
A related SO exchange: https://stackoverflow.com/a/52208194
Basically, if you want to hide the links, it's best to remove their tab order. That underlying decision though may be subjective, and so I'd argue that folks using SRs and keyboards to navigate should be able to access the links for the same reasons anyone else might need them. Didn't know about the wrap
option, which is great! In that case I'd advocate for using aria-labelledby
as the default.
Others may disagree. I forgot that, just reading through the content, a header will be read twice if you remove aria-hidden
, but I'm unsure how either NVDA or JAWS might deal with having both a label and a hidden attribute. But at least with VoiceOver, this works great:
<h2 id="what-exactly-is-a-portal">
<a href="#what-exactly-is-a-portal" aria-labelledby="what-exactly-is-a-portal" aria-hidden="true">
<span class="icon icon-link"></span>
</a>What exactly is a portal?
</h2>
I don't know of any articles unfortunately. Perhaps I should write one! Here is a relevant bit of the spec on how this affects SR users. https://www.w3.org/TR/WCAG20-TECHS/ARIA7.html
from remark-autolink-headings.
An even better solution suggested by @smhigley would be to pull the link out of the heading tag altogether. If you just need the heading for positioning purposes, this should work better than trying to hide the link!
<div> <!-- outer div for positioning the link -->
<a href="#what-exactly-is-a-portal" aria-labelledby="what-exactly-is-a-portal">
<span class="icon icon-link" aria-hidden="true"></span>
</a>
<h2 id="what-exactly-is-a-portal">What exactly is a portal?</h2>
</div>
from remark-autolink-headings.
https://twitter.com/wooorm/status/1194902349610921984
from remark-autolink-headings.
I love this, but the downside is that it wouldnt be a good option for a default, because of the English prefix and suffix 🤔
from remark-autolink-headings.
Related Issues (13)
- Emoji leads to weird slug HOT 12
- Links are not added to headings
- Compatible with `remark-slug` version 5 HOT 2
- Bug: version 5.0.0 on npm is outdated HOT 3
- Add behavoir for fixed headers. HOT 9
- `behaviour` doesn't follow American spelling standards HOT 5
- Support ignoring headings HOT 9
- `contentDefaults` must have `children: []`
- latin char id link problem HOT 4
- No Id, No href attribute HOT 1
- Generated link anchor doesn't have an icon HOT 1
- Include example on how to style <span class="icon icon-link"> HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remark-autolink-headings.