You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/components_guide_web/lib/components_guide_web/templates/accessibility_first/properties-cheatsheet.html.eex
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@
37
37
<p>You can hide using a large range of techniques. What you first want to ask is, from whom do I want to hide the content?
38
38
39
39
<%=list[
40
-
"Hide to **everyone**.",
40
+
"Hide from **everyone**.",
41
41
"**Screen reader affordance:** hide to sighted users, but show to screen reader users.",
42
42
"**Visual affordance:** hide to screen reader users, but show to sighted users."
Copy file name to clipboardExpand all lines: apps/components_guide_web/lib/components_guide_web/templates/react_typescript/testing.html.md
+60-15Lines changed: 60 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,41 @@
1
-
## Behavior and markup > implementation details
1
+
## Use Roles First
2
2
3
-
## Accessibility-first testing: a standard-based approach
3
+
Most semantic HTML elements have an implicit role. This role is used by accessibility tools such as screen readers. But as we’ll explain, ou can also use it to write easy-to-understand tests.
4
4
5
-
- Build components
6
-
- Test components work as expected
7
-
- Test-drive components
8
-
- Learnable & deterministic
5
+
Because the ARIA specs are more recent than HTML 1.0, it clarifies HTML and provides improved names for a lot of the traditional HTML elements. The names used are more what everyday users would use too, such as `link` rather than `a`.
6
+
7
+
### Roles are better than Tag Names
8
+
9
+
Roles are better than tag names, as they generalize towards the user behaviour not the nitty-gritty of HTML specifics.
10
+
11
+
As an example, `<input type="text">` and `<textarea></textarea>` both have the role **textbox**. A user probably does not care for the difference — it’s just a text field that they can type into.
12
+
13
+
These roles allow us to think in the language that our users would use:
14
+
15
+
- The **save**_button_
16
+
- The **email**_text field_
17
+
- The **primary**_navigation_
18
+
- The **notifications**_icon image_
19
+
- The _**search** field_
20
+
- The **remember me**_checkbox_
21
+
22
+
### Roles are better than Test IDs
23
+
24
+
Test IDs are something that allow us to find specific elements on the page. They can seem especially necessary in a component system, since our component structure is not surfaced if we render our component tree to HTML.
25
+
26
+
The problem is that Test IDs are _only_ used for automated testing — they don’t affect the user’s experience at all.
27
+
28
+
So something that relies on Test IDs to work might still pass, but still produce an issue for end users! So using them does not give us that much more confidence that what we are implementing actually works.
29
+
30
+
It would be better if we could test the same experience as our users. If we could take the same path they use when first coming to a page and they begin to understand what’s there.
31
+
32
+
A screen reader user has this exact experience. They arrive at a page, and are able to hear what sections and elements are available. They are able to jump to a specific section or element and interact with it. And they get feedback telling them exactly what the state of the world is as they interact.
9
33
10
-
## Build components
34
+
This sounds exactly what we would desire for our automated tests! We want to find elements on the page, interact with them, and get feedback that they are working correctly.
11
35
12
-
Most semantic HTML elements have a role.
36
+
This is what accessibility-first testing allows us to achieve. And as a massive bonus, it lets us create an accessible experience from day one. We can be on a path to creating a fantastic user experience too.
37
+
38
+
## Available Roles
13
39
14
40
<tableclass="text-left table-fixed">
15
41
<thead>
@@ -18,7 +44,7 @@ Most semantic HTML elements have a role.
0 commit comments