1
- ** This document is used as aria/a11y reference for future developers**
1
+ # Background
2
+
3
+ This document is used as aria/accessibility(a11y) reference for future developers.
4
+
5
+ There are a lot of a11y problems in the Fomantic UI library. This ` aria.js ` is used
6
+ as a workaround to make the UI more accessible.
7
+
8
+ The ` aria.js ` is designed to avoid touching the official Fomantic UI library,
9
+ and to be as independent as possible, so it can be easily modified/removed in the future.
10
+
11
+ To test the aria/accessibility with screen readers, developers can use the following steps:
12
+
13
+ * On macOS, you can use VoiceOver.
14
+ * Press ` Command + F5 ` to turn on VoiceOver.
15
+ * Try to operate the UI with keyboard-only.
16
+ * Use Tab/Shift+Tab to switch focus between elements.
17
+ * Arrow keys to navigate between menu/combobox items (only aria-active, not really focused).
18
+ * Press Enter to trigger the aria-active element.
19
+ * On Android, you can use TalkBack.
20
+ * Go to Settings -> Accessibility -> TalkBack, turn it on.
21
+ * Long-press or press+swipe to switch the aria-active element (not really focused).
22
+ * Double-tap means old single-tap on the aria-active element.
23
+ * Double-finger swipe means old single-finger swipe.
24
+ * TODO: on Windows, on Linux, on iOS
2
25
3
26
# Checkbox
4
27
@@ -10,7 +33,8 @@ The ideal checkboxes should be:
10
33
<label ><input type =" checkbox" > ... </label >
11
34
```
12
35
13
- However, related styles aren't supported (not implemented) yet, so at the moment, almost all the checkboxes are still using Fomantic UI checkbox.
36
+ However, related CSS styles aren't supported (not implemented) yet, so at the moment,
37
+ almost all the checkboxes are still using Fomantic UI checkbox.
14
38
15
39
## Fomantic UI Checkbox
16
40
@@ -21,64 +45,52 @@ However, related styles aren't supported (not implemented) yet, so at the moment
21
45
</div >
22
46
```
23
47
24
- Then the JS ` $.checkbox() ` should be called to make it work with keyboard and label-clicking, then it works like the ideal checkboxes.
48
+ Then the JS ` $.checkbox() ` should be called to make it work with keyboard and label-clicking,
49
+ then it works like the ideal checkboxes.
25
50
26
- There is still a problem: Fomantic UI checkbox is not friendly to screen readers, so we add IDs to all the Fomantic UI checkboxes automatically by JS.
51
+ There is still a problem: Fomantic UI checkbox is not friendly to screen readers,
52
+ so we add IDs to all the Fomantic UI checkboxes automatically by JS.
53
+ If the ` label ` part is empty, then the checkbox needs to get the ` aria-label ` attribute manually.
27
54
28
55
# Dropdown
29
56
30
- ## ARIA Dropdown
31
-
32
- There are different solutions:
33
-
34
- * combobox + listbox + option
35
- * menu + menuitem
36
-
37
- ``` html
38
- <div >
39
- <input role =" combobox" aria-haspopup =" listbox" aria-expanded =" false" aria-controls =" the-menu-listbox" aria-activedescendant =" item-id-123456" >
40
- <ul id =" the-menu-listbox" role =" listbox" >
41
- <li role =" option" id =" item-id-123456" aria-selected =" true" >
42
- <a tabindex =" -1" href =" ...." >....</a >
43
- </li >
44
- </ul >
45
- </div >
46
- ```
47
-
48
-
49
57
## Fomantic UI Dropdown
50
58
51
- There are 2 possible solutions about the role: combobox or menu
59
+ Fomantic Dropdown is designed to be used for many purposes:
52
60
53
- 1 . Detect if the dropdown has an input, if yes, it works like a combobox, otherwise it works like a menu
54
- 2 . Always use "combobox", never use "menu"
61
+ * Menu (the profile menu in navbar, the language menu in footer)
62
+ * Popup (the branch/tag panel, the review box)
63
+ * Simple ` <select> ` , used in many forms
64
+ * Searchable option-list with static items (used in many forms)
65
+ * Searchable option-list with dynamic items (ajax)
66
+ * Searchable multiple selection option-list with dynamic items: the repo topic setting
67
+ * More complex usages, like the Issue Label selector
55
68
56
- According to the public discussion with fsologureng in chat channel:
69
+ Fomantic Dropdown requires that the focus must be on its primary element.
70
+ If the focus changes, it hides or panics.
57
71
58
- > 2023-03-13 14:52:00 UTC
59
- >
60
- > wxiaoguang: Yup, the "language dropdown" is arguable (menu or combobox). It's the only one we need to mark it as combobox if you strongly prefer.
61
- > But for others (Create Repo / Profile / Reaction Menu / Issue Context Menu), I think they are not suitable to be combobox.
62
- >
63
- > fsologureng: I repeat an argument stated in my first comment: "On the old web there were many menus implemented with an auto-submit select,
64
- > but that didn't change the fact that they were selects for screen readers.
65
- > That is the case with Fomantic dropdowns as used in Gitea.
66
- > Implementations of auto-submit select menus fell behind in modern web design precisely because they are not usable or accessible."
67
- >
68
- > wxiaoguang: If you strongly prefer, we can mark all "dropdown" as "combobox", never use "menu" in code. Do you think this solution is clear enough?
69
- >
70
- > fsologureng: Yes. I think it will provide better accessibility because is more coherent with the current fomantic based implementation.
72
+ At the moment, ` aria.js ` only tries to partially resolve the a11y problems for dropdowns with items.
71
73
72
- Reference :
74
+ There are different solutions :
73
75
74
- * Combobox :
76
+ * combobox + listbox + option :
75
77
* https://www.w3.org/WAI/ARIA/apg/patterns/combobox/
76
- * A combobox is an ** input widget** with an associated popup that enables users to select a value for the combobox from
78
+ * A combobox is an input widget with an associated popup that enables users to select a value for the combobox from
77
79
a collection of possible values. In some implementations, the popup presents allowed values, while in other implementations,
78
80
the popup presents suggested values, and users may either select one of the suggestions or type a value.
79
- * Menu :
81
+ * menu + menuitem :
80
82
* https://www.w3.org/WAI/ARIA/apg/patterns/menubar/
81
- * A menu is a widget that offers a list of choices to the user, such as a set of ** actions or functions** .
83
+ * A menu is a widget that offers a list of choices to the user, such as a set of actions or functions.
84
+
85
+ The current approach is: detect if the dropdown has an input,
86
+ if yes, it works like a combobox, otherwise it works like a menu.
87
+ Multiple selection dropdown is not well-supported yet, it needs more work.
88
+
89
+ Some important pages for dropdown testing:
90
+
91
+ * Home(dashboard) page, the "Create Repo" / "Profile" / "Language" menu.
92
+ * Create New Repo page, a lot of dropdowns as combobox.
93
+ * Collaborators page, the "permission" dropdown (the old behavior was not quite good, it just works).
82
94
83
95
``` html
84
96
<!-- read-only dropdown -->
0 commit comments