-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs(input): better accessibility in examples #11079
Conversation
a9c19fa
to
bad9343
Compare
I wonder if it is a good idea to use the <label>
Some label:
<input type="text" name="input" ng-model="example.text" />
</label> |
@gkalpak because this is primarily for developer education, I opted for explicit labels on purpose. A common accessibility problem is to leave off the You can read about implicit vs. explicit labeling vs. aria-labelledby here: http://www.paciellogroup.com/blog/2011/07/html5-accessibility-chops-form-control-labeling/ |
Interestingly enough, although the author seems to suggest using |
The support differences look pretty minimal to me. This post is also from 2012, so take it with a grain of salt. |
bad9343
to
f102135
Compare
👍 |
+1 please fix a11y in the docs it's very very bad, all the angularJS books have not a11y just like the docs, wrapped labels are fine in my testing, yes it's less code and will look more readable, any a11y we can get the better! |
<label for="input">Single word:</label> | ||
<input id="input" type="text" name="input" ng-model="example.text" | ||
ng-pattern="example.word" required ng-trim="false"> | ||
<span role="alert"> |
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.
Does role=alert
announce assertively/immediately? Is that the desired experience for a form validation?
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.
When I tested it, it matched the speed that the visual message would come up in context to what you're typing...it was especially useful for validations related to input length, so you'd know exactly when the error occurred.
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.
That's really cool! Good to know.
Huge +1 in general. Great to see improved accessibility in the docs, and the |
f102135
to
f97f931
Compare
Thanks for the feedback! I've simplified a lot of the labeling based on comments in this PR. |
@ckundo @gkalpak I did a search for
Can you take another look if you get a chance? Thanks so much. |
|
||
<label>Single word: | ||
<input type="text" name="input" ng-model="example.text" | ||
ng-pattern="example.word" required ng-trim="false"> |
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.
Alignment with the attributes above is not quite right.
Is there some guideline around line length? 80 characters is a sane guideline, but I don't know if the project adheres to that. @gkalpak do you know? |
@marcysutton it occurred to me that the |
<hr> | ||
<p ng-class="style">Using String Syntax</p> | ||
<input type="text" ng-model="style" placeholder="Type: bold strike red"> | ||
<label><input type="text" ng-model="style" placeholder="Type: bold strike red"> |
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.
Is this missing a closing tag? </label>
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.
It is indeed! Good catch.
@@ -144,7 +144,7 @@ | |||
* | |||
* The correct way to write it: | |||
* ```html | |||
* <img ng-srcset="http://www.gravatar.com/avatar/{{hash}} 2x"/> | |||
* <img ng-srcset="http://www.gravatar.com/avatar/{{hash}} 2x" alt="Description" /> |
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.
I suggest the same change is made to the buggy way above.
Since this example is about src
vs ngSrc
, we don't want to distract the reader into thinking alt
has anything to do with that.
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.
Gotcha. That makes sense to me.
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.
@gkalpak @marcysutton why not add the alt
to both?
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.
Done! Great suggestion.
Besides the formatting fixes, I think the @marcysutton thanks a million for this work. Keep it up! edit: |
It generally LGTM. Really great work ! 👍 @marcysutton A couple of notes:
|
Thanks again for your thorough review, this is awesome!
If it's okay to leave this all in one branch, it will save me from having to do the work of splitting it up and creating additional PRs. In the future I'll try to break it up though. I know it's a big one! Thanks again for all your help. |
@marcysutton thanks, LGTM! 👍 |
<input ng-model="name"> <br> | ||
<textarea ng-model="html"></textarea> <br> | ||
<input ng-model="name"> <br/> | ||
<textarea ng-model="html"></textarea> <br/> |
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.
These should have labels too. Oops! I'll fix them up later.
The input and ngModel docs examples have no labels or accessible error handling. They could do more to encourage accessibility best practices. This change does two things:
Even though Angular 2.0 is coming soon, these docs will live on with the 1.0 project so it makes sense to show more accessible examples. (Better late than never.)