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

Abide accessibility #10699

Merged
merged 14 commits into from
Jan 30, 2018
Merged

Abide accessibility #10699

merged 14 commits into from
Jan 30, 2018

Conversation

Owlbertz
Copy link
Contributor

@Owlbertz Owlbertz commented Oct 5, 2017

Improved Abide accessibility, based on issue #10552.
As this PR will not create a full WCAG compliance, it is at least a step towards it.

Maybe @udf2457 could give some feedback.

Set aria-invalid attribute when something is not valid, see [here (Mailinglist)](http://lists.w3.org/Archives/Public/public-pfwg/2015Jul/0031.html) and [here (Spec)](https://www.w3.org/TR/wai-aria-1.1/#aria-invalid).
Added aria-onerrormessage attributes where needed. See [here (Spec)](https://www.w3.org/TR/wai-aria-1.1/#aria-errormessage).
Fixed multiple elements having the same ID.
@udf2457
Copy link

udf2457 commented Oct 5, 2017

@Owlbertz Normally I'd love to, but I'm drowning in work at the moment, so it might be 2–3 weeks (at least) before I can get round to looking properly at it. So for the moment the best I can do is thank you for your hard work. ;-)

@atainton
Copy link

@udf2457 any update, would be great for a disabled user to know when there are validation errors

@Owlbertz
Copy link
Contributor Author

Owlbertz commented Nov 28, 2017

@atainton Don't hesitate to check this out and give feedback on your own .

@udf2457
Copy link

udf2457 commented Nov 28, 2017

@atainton et al.

I'm afraid I'm currently a bit backlogged at work - more backlogged than I was in October, which apparently is somehow humanly possible ! So realistically I'm not going to be able to do much testing of the above commit until much before the end of the year.

Sorry to disappoint, but such is life !

@ncoden ncoden self-assigned this Dec 24, 2017
@ncoden
Copy link
Contributor

ncoden commented Dec 24, 2017

I'll check this. I want to learn about accessibility and this is a good opportunity for that ;)

@Owlbertz
Copy link
Contributor Author

@ncoden glad to hear that.
I don't want to advert for myself too much, but if you want to get started with accessibility maybe my collection of related ressources might be helpful.

Changes:
* rename IDs of inputs/descriptors
* add `aria-describedby` and `aria-live="assertive` when required
@ncoden
Copy link
Contributor

ncoden commented Jan 8, 2018

@Owlbertz I added some aria attributes to the docs and tested it. It works well ;). I am particulary impressed by the aria-live="assertive" to "pop" an error message to the user.

The next step is to add these attributes when we can. I'm thinking to aria-live for all [data-abide-error], and aria-describedby for all .form-error and [data-form-error-for].

What do you think ?

@ncoden ncoden added this to the 6.4.4 milestone Jan 16, 2018
@ncoden
Copy link
Contributor

ncoden commented Jan 16, 2018

@Owlbertz

  • Set [aria-live] attribute on [data-abide-error], according to the a11yErrorLevel option.
  • Set [aria-describedby] attribute on field, targetting the first form error.
  • Set [for] attribute on form errors labels, targetting their field.
  • a11yAttributes option to disable all this. For now, it does not disable aria-invalid.
  • Full documentation. Good enough like that
  • Do not add "[aria-describedby]" on fields by form errors on init Actually, the W3C examples set [aria-describedby] from the begining. And Chromevox do not spell an hidden error field.
    --
  • Visual tests.
  • Unit tests.
    --
  • Set [role=alert] attribute on form errors

@ncoden
Copy link
Contributor

ncoden commented Jan 22, 2018

Poke @Owlbertz. Would you have some time to review this ? :)

@ncoden ncoden merged commit 506b9ec into foundation:develop Jan 30, 2018
ncoden added a commit to ncoden/foundation-sites that referenced this pull request Jun 16, 2018
…or v6.5.0

51a2558 Implemented accessibility for Abide.
dfae510 Improved accessibility of Abide page.
3e512b9 Added unittests for aria-invalid in Abide.
835cf04 docs: improve accessibility of abide examples
07b2d76 feat: add [aria-live] on [data-abide-error] on form validation
88abca7 feat: automatically add [aria-describedby] and [for] attributes in Abide
d1acd32 feat: add `a11yAttributes` option on Abide to disable a11y attribute insertion
f55efd5 feat: set `[aria-live]` on Abide global erros on init
6cf6619 docs: add basic doc about a11y attributes in Abide
32efbc2 test: add unit tests for Abide.addA11yAttributes()
8e7fa06 test: add unit test for Abide.addGlobalErrorA11yAttributes()
edf21d2 test: add visual test for Abide accessibility
c6a6906 fix: fix side-effect of jQuery .filter() in Abide.addA11yAttributes
c6e4b56 feat: add [role=label] to all form errors in Abide

Co-Authored-By: Nicolas Coden <nicolas@ncoden.fr>
Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
@ahukkanen
Copy link
Contributor

I don't know if @ncoden is still around but I would be interested in why you decided to add the aria-describedby to point to the error field if the aria-describedby attribute is not defined for the field.

This causes the screen reader to announce the error element event before the user has done anything wrong. I created a quick sample here what happens (try it out with a screen reader):
https://jsfiddle.net/f3g2rx1j/show

The screen reader is announcing here the following:

  • "Text Required" field
  • Editable
  • Required
  • Yo, you had better fill this out, it's required.
  • (On some screenreaders it reads also the placeholder after the aria-describedby element)

We received feedback from accessibility auditors that this can be confusing for users using the assistive technologies. The user would not expect the error text to describe the contents of the input field. Instead, the screen reader should announce the error only when it becomes visible on the page, i.e. when the user leaves the field without entering anything to it (or when they return back to the field after first leaving it empty).

If there is a valid reason why you added the aria-describedby attribute to point to the first error message, we would be interested to hear the reasoning to better understand this and also to justify its use for the accessibility experts.

The described current behavior would be completely fine in case it happened when the error was already visible on the page, i.e. when the user returns back to the field after they first left it empty. But now that they hear the error description when it is still invisible on the screen, it creates confusion.

Could you share some insight on this?


Here's the example code if it disappears for some reason from JSFiddle:

<!DOCTYPE html>
<html>
<head>
<title>Foundation test</title>
<!-- Compressed CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/css/foundation.min.css" crossorigin="anonymous">

<!-- Compressed JavaScript -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/foundation-sites@6.7.4/dist/js/foundation.min.js" crossorigin="anonymous"></script>
</head>
<body>
  <form data-abide novalidate data-abide="true" data-validate-on-blur="true" data-live-validate="true">
    <label>
      Text Required
      <input type="text" placeholder="Go to this field with a screenreader (don't type anything)" required>
      <span class="form-error">
        Yo, you had better fill this out, it's required.
      </span>
    </label>
  </form>

<script>
$(document).ready(() => {
  $("body").foundation();
});
</script>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants