openui / openui/open-ui

[menu] navigational <menuitem>

Open
#1,447 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MDX
Stars
4.5k
Forks
226
Avg merge
2d 22h
Merged PRs (30d)
4

Description

I've been reading the Menu Elements design doc and part of it leapt out at me:

In Issue #1193 we discussed the possibility of supporting the Navigation Menubar Pattern with our proposal, and primarily due to accessibility concerns, ultimately resolved not support it. Conceretely, this means that our proposal will discourage the use of embedding <a> hyperlinks in menus alongside menuitems, likely through the content model and default styles.

Page navigation can still be triggered with menu items, but will have to be done so with JavaScript event listeners that handle the activation of the menu item, and do something like location.href = foo; in response. We expect that this will result in our menu elements not being used as primary navigation components on web pages; rather navigation menu items as we just described will be one-offs, much like the following “Training” example, which opens a new page upon activation, but does not need to be enumerated as anything other than an application menu item by screen readers

While I understand the concerns laid out in #1193, and I'm not really looking to rehash that discussion. However, it seems the objection is against menus that are purely navigational, while there are genuine use-cases to have a mix of navigational and functional items. If it's worth anything at all, I feel quite strongly that new elements should try and meet as many use cases as possible without requiring JavaScript.

Some background: I recently created a menu component for a website I am working on, and I'm trying to make the site as functional as possible when JavaScript is disabled. This means that some of my menu items are actually navigation links, such as those that link to help pages or to sign out. The JavaScript-only ones are disabled by default and then enabled by JavaScript when the component mounts.

As I said, navigational menuitems are actually quite a common pattern. It's used on various social media sites as well as right here on Github:

Image

In Github's menu there's a mix of JavaScript-based menu items and navigational-based ones. Note that it's not marked up with aria attributes and roles as a menu (it's just a list of buttons and links), but it certainly looks and quacks like a popover menu. Here's a similar example from Anaplan's dashboard pages:

Image

It seems like #1104 could be a potential solution here, so maybe it's not much of an issue, but it feels important to call out given the text in the explainer. My actual preferred solution would be to have navigation available as a fallback. For instance, I could have a theme selector which updates the body class with JavaScript if enabled, but navigates to, e.g. ?theme=dark if JavaScript is disabled.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Menu Elements design doc and read Issue #1193, then compare the possible approach in #1104 with the mixed functional and navigational examples described here. Done should mean that the supported behavior for navigational menu items, including the JavaScript-disabled fallback, is resolved and reflected in the proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
html, javascript
Domain
accessibility, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.