Skip to content

Commit 40c9d4c

Browse files
Completing the initial ADR
1 parent e0e7ab0 commit 40c9d4c

1 file changed

Lines changed: 65 additions & 9 deletions

File tree

docs/architecture-decisions/0005-implement-an-accessible-navigation-system.md

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ The markup which the user finally interacts with looks like this:
3737

3838
The issue is that the element triggering the flyout menu (the
3939
`<span class="sub-arrow"></span>` tag) is _inside_ the anchor element, making it
40-
challenging for users of assistive technologies to separate their interactions
41-
with the menu link and the submenu toggle.
40+
challenging (if not impossible) for users of assistive technologies to separate
41+
their interactions with the menu link and the submenu toggle.
4242

4343
The current release of SmartMenus (1.2.1) does not support placing this toggle
4444
element outside of the link element, so it will be necessary to replace it with
@@ -84,7 +84,7 @@ CodePen](https://codepen.io/matt-bernhardt/pen/poBRKrY).
8484
This menu, when properly configured, appears to implement all the best practices
8585
for an accessible navigation menu for web application.
8686

87-
#### Drawbacks
87+
#### Drawbacks of Accessible Menu
8888

8989
There are several significant drawbacks to using this menu library.
9090

@@ -123,14 +123,57 @@ found described in [several](https://purecss.io/menus/) [places](https://devsnap
123123

124124
While attempting to implement the Accessible Menu library, we asked for feedback
125125
about our progress from Rich Caloggero, who was involved in our earlier
126-
accessibility testing. Rich helpfully assembled a mockup demonstrating a usable
126+
accessibility testing. Rich helpfully assembled a [mockup](https://richcaloggero.github.io/tools/createNavigation.html) demonstrating a usable
127127
navigation system with very little javascript (and no stylesheets).
128128

129-
* Pros: This section needs to be filled out.
129+
#### Benefits of a bespoke approach
130+
131+
The amount of javascript which is needed is potentially very, very small. The
132+
initial snippet which Rich provided was just this:
133+
134+
```js
135+
$submenus = document.querySelectorAll("nav ul ul");
136+
$submenus.forEach(x => x.setAttribute("hidden", ""));
137+
$nav.removeEventListener("click", clickHandler);
138+
$nav.addEventListener("click", clickHandler);
139+
140+
function clickHandler (e) {
141+
if (e.target instanceof HTMLButtonElement) {
142+
e.preventDefault();
143+
const menu = e.target.parentElement instanceof HTMLLIElement? e.target.nextElementSibling : e.target.parentElement.nextElementSibling;
144+
menu.hidden = not(menu.hidden);
145+
e.target.setAttribute("aria-expanded", menu.hidden? "false" : "true");
146+
} // if
147+
} // clickHandler
148+
```
149+
150+
If we choose HTML elements which bring native functionality (`button`, `a`, and
151+
header tags, for example) then we not only need less javascript but we are more
152+
likely to match functionality which users are already familiar with using. The
153+
only conceptual need we are solving is how to expand and collapse a submenu -
154+
everything else is already present.
155+
156+
The styling rules required for this approach should likewise be minimal.
157+
158+
#### Drawbacks of a bespoke approach
159+
160+
The maxim "if you aren't using a framework, you are building one" applies here.
161+
While the amount of code required is small, it is still code for which we are
162+
responsible. That code will require us to commit to maintaining the knowledge of
163+
how it works and how to troubleshoot it, and to commit to having the bandwidth
164+
to respond to problems as they are reported.
165+
166+
This bespoke approach is also not just javascript, but all the associated
167+
styling rules for the menu to be rendered in both a vertical and horizontal
168+
layout.
169+
170+
In addition, because this code is so small, it has likely been written by some
171+
other group of developers - and it would be preferable to leverage their work
172+
rather than repeat it.
173+
174+
Ultimately, though, the review which we've conducted of existing menu libraries
175+
has not identified such a suitable existing library at this time.
130176

131-
* Cons: We will be responsible for maintaining the entirety of this solution,
132-
and will need to preserve the bandwidth and skills to fulfill this
133-
responsibility.
134177

135178
## Decision
136179

@@ -141,6 +184,19 @@ If this proves sustainable, the feature will be considered for promotion to the
141184
overall style library in order to make the feature available to our other
142185
web applications.
143186

187+
Our ultimate preference for an externally-defined navigation library will mean
188+
that we continue to monitor the development of both SmartMenus and Accessible
189+
Menu, with an eye toward adopting one should a suitable version be released.
190+
191+
144192
## Consequences
145193

146-
This section needs to be filled out.
194+
We will work from the prototypes and examples which Rich has provided and write
195+
our own bespoke solution for navigation menus in Omeka. This solution will:
196+
197+
1. Make use of appropriate HTML tags as much as possible, with toggles for
198+
triggering submenus separate from the navigation links - at any depth.
199+
1. Implement minimal javascript.
200+
1. Include styling rules for both a horizontal and vertical implementation,
201+
while the markup and javascript for each will be the same.
202+
1. Be evaluated for promotion to our style guide.

0 commit comments

Comments
 (0)