Commit e69f1fd
committed
Define new helper for tab links, with aria
** Why are these changes being introduced:
We want to add an `aria-current="page"` attribute to the currently
active tab link on a results page, so that assistive technologies can
parse which is the active tab. This requires a conditional link_to call,
as well as an update to the javascript which handles tab changes.
** Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/use-180
** How does this address that need:
Because we can't (apparently) write a conditional inside an argument to
a link_to call, we have to maintain the conditional check elsewhere -
so to prevent the source_tabs partial from becoming a mess of multiple
conditionas, we define a new search helper function, link_to_tab. This
takes a string as an argument, and is capable of outputting both a link
to the active tab, as well as to an inactive tab.
We also update loading_spinner.js to be able to maintain the state of
the aria-current attribute.
** Document any side effects to this change:
The tests for this helper function _should_ be robust enough, but I
worry that they're a bit too clever. I didn't want to just write a
string comparison assertion, because that feels very fragile given how
much this partial has been changing lately. The assertions as written
should focus on the values being present or not, but still be robust to
other changes.
Also note that, for now, the source_tabs partial is still a bit bespoke
in that there are explicitly two calls to the various tabs. I'd
originally intended to define a list in the controller, but managing the
list of tabs in this way feels awkward and like it doesn't gain anything
since the tabs are entwined with so much of the rest of the application.
Abstracting the tab order and contents to a list doesn't save us from
other complexity.1 parent 3f1acf8 commit e69f1fd
File tree
4 files changed
+41
-11
lines changed- app
- helpers
- javascript
- views/search
- test/helpers
4 files changed
+41
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
25 | 38 | | |
26 | 39 | | |
27 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 4 | + | |
| 5 | + | |
12 | 6 | | |
13 | 7 | | |
14 | 8 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
202 | 223 | | |
203 | 224 | | |
204 | 225 | | |
| |||
0 commit comments