-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Use footnoteLabel as an aria-label on the section element rather than in an h2 #60
Comments
Hi!
You mean labels on each footnote call right? I am not sure it is for this use case: namely a footnote section.
Because they use out of date dependencies. From before GitHub added support for footnotes.
Given that their result is due to out of date dependencies, I do not think this proves your reading of what people want.
What flexibility do you want and why?
This behavior changed in a major: https://github.com/syntax-tree/mdast-util-to-hast/releases/tag/12.0.0, I am not interested in changing the default behavior again. I am open to ideas on options, if the results make sense. Note that we use ASTs in remark/rehype. You can already change anything you want. You can remove headings. You can add attributes.
Well, the heading could also remain as it was! |
Thanks for your answer! TL;DR: I think aria-label is a better solution here, but i agree the current default behavior shouldn't change.
I agree we should have a section, and only one for all the footnotes. The aria-label would go on that section (and replace the h2). The output html i have in mind would be like: <section data-footnotes="" class="footnotes" aria-label="foonotes">
<ol>
<li id="user-content-fn-1">
<p>a footnote <a href="#user-content-fnref-1" data-footnote-backref="" class="data-footnote-backref" aria-label="Back to content">↩</a></p>
</li>
</ol>
</section> I'm not an accessibility expert, but it looks to me like we do not need aria-labels on each footnote. We have the one for "back-to-content" and i guess the rest would be clear for a screen reader.
Well, GitHub is not showing this h2, it is hidden with a bit of css. So i think even GitHub does not want to show this on a regular screen, only have it read by screen readers. (The css is the same trick mentioned in the stack overflow answer about putting text that will be screen-reader specific, but in second place after using aria-label.)
I would like to be able to remove the h2 easily, and have an aria-label on the section instead. This is because:
I don't think the default behavior should change. In fact it would probably be a bad idea. But i'll be very happy to have another option
I admit i do not know about this! Would this require writing code for a plugin that would handle the AST?
It could! But i wouldn't get the flexibility i am looking for. Another related note is that due to the way the footnoteLabel value is being tested, i cannot just set this option to an empty string, it is also falsey and will display the default English "Footnotes". That would have been a lazy option for achieving what i am looking for, but i think we can do better and remain accessible. This might be intentional in order to insure that we always have a footnoteLabel, even if it is in the wrong language. |
I wouldn’t call myself an expert either but that’s not how
Finally, the first rule of ARIA is to not use ARIA: https://www.w3.org/TR/using-aria/#rule1. The heading strategy is normal HTML without ARIA. It works. If you want don’t want to show it, you can hide it with CSS. When in doubt, I’d prefer following experts, and GitHub + Kitty doing what’s done here, feels pretty solid!
https://github.com/syntax-tree/mdast-util-to-hast#css.
I can somewhat understand this because its the “right thing” to do. We could make that configurable.
It would have been appreciated if you’d have shared this related issue and root problem earlier.
Yes. Anything can be done by transforming the AST. |
I admit my only source here is the stack overflow post, where the example given feels pretty similar to what i had in mind. I do find it surprising that this case (add text only for the screen reader) isn't managed by the standard and requires some css. But i just saw that tailwind includes the sr-only class in its utilities, so as you are pointing out, a good number of people with more knowledge than me seem to agree on this. Feel free to close this issue and sorry for the noise. I'll get back to trying to fix the translation issue in Astro. |
Yeah, it is similar, but not the same:
I think it’s in line with how the web works, namely the other way around. Similar to how the “mobile-first” design idea (start with “mobile” screens and add CSS for bigger screens) suits the web, here we start with HTML only making sense on its own, and then we add CSS on top to change things for visual users.
No problem at all!
Okay, I will close the issue, but I am open to adding concrete features for different output. E.g., a tag name other than
Feel free to ping me if the discussion there is useful for me to weigh in on! Good luck and all the best! :) |
What do you think about adding more flexibility with respect to the footnotes component for footnotes? @wooorm I was hoping to change the My use-case for this is that I have a |
Hi! This issue was closed 3 years ago. A new discussions is a better place to discuss your situation. Anyway: sure, it’s in the docs, see |
Sorry... will do that next time! Thanks for the reply and the patience. |
Initial checklist
Problem
When using footnotes, the following html will be output:
I think this is generated by this part:
mdast-util-to-hast/lib/footer.js
Lines 104 to 125 in dfd724a
I understand this is to match the way GitHub handles footnotes.
However, this might not be the best way to make things accessible, and an
aria-label
on thesection
element might be better than anh2
with a custom class that will require dedicated css, see here:https://stackoverflow.com/questions/26032089/in-html-how-can-i-have-text-that-is-only-accessible-for-screen-readers-i-e-fo
I haven't investigated how, but a number of projects that ultimately depend on this package display their footnotes without this
h2
. See this Gatsby example: https://using-remark.gatsbyjs.org/hello-world-kitchen-sink/#footnotes (Although this is missing anaria-label
and i guess less accessible. I mention this to show that end users do want to remove thish2
, which is hidden with css on GitHub.)Apologies if i am missing something! But so far i can see that the text that will go in the
h2
can be customized, but we do not have more flexibility. Thea
for the backref is using anaria-label
so maybe there is something i do not understand properly here.Solution
This is a package with close to 4 million weekly downloads so i suppose changes to behaviour and configuration need to be considered carefully.
Maybe a new boolean option could be added that would trigger adding the
footnoteLabel
as an aria-label on thesection
, and not adding theh2
.The default behaviour (i.e. when that new option is not set) would remain the same.
Alternatives
Although i haven't investigated how, projects relying on this one do have solutions to get rid of this
h2
.The alternative is to let users add the css rules from GitHub to manage the
sr-only
class:It feels a bit clunky to me though and
aria-label
seems like a more standard option that will output less clutter.Ideally, it would even be possible to let users customize the html inserted, but it might be best to keep things minimal here? I suppose what is happening with Gatsby and others is that they wrote their own plugins to manage this.
The text was updated successfully, but these errors were encountered: