-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[a11y] sub nav component contains nested interactive elements #15005
Comments
Possible fixes for this:
The downside is we then have a "Firefox" repeated twice in the nav, but maybe that's OK? I always forget the title/icon is clickable.
|
Does it have to be a button, or a div with some interactive role better representing the markup output would suffice? Does the content necessarily have to nest inside the button, or it can be outside of it structurally, but just styled in a way it behaves today — as if the link is in the foreground getting the events for its own hitzone only, and the button being in background underneath, receiving the dropdown hits outside of the actual link to manipulate the submenu…? |
This is a good question! It uses the Protocol details component, which injects a |
Ok yeah, looking at the code perhaps this is the most straight forward path. We can just never inject a |
The details component behaves rather nicely and has good a11y defaults, as compared to e.g. other collapsible menu instances: mozilla/protocol#947 — so would stick to it if possible, only moving things around. The issue with interactive elements inside button roles is that AT turns that all into plaintext basically, so they can't be navigated. And it doesn't matter if that's button, or details' summary — any link inside these mostly won't work with AT (that basically don't "see" it there, or add it to the document outline for interaction). So my thought was to keep the existing functionality, add some placeholder for the dropdown button, and move the category link outside — as it itself is not a part of the button/dropdown anyways, it only coincidentally shares the same physical space;) — and stack it with z-index to basically do what it does now. I haven't looked into the implementation details honestly, but was thinking about changing the current:
into
that would be placed below the link to act as the hitzone around it, but don't know how much of the mzp details magic is tied to the actual heading usage. |
I'm not sure your suggestion can be implemented with the current details JS and the expectations it makes, but I'll take a closer look. I don't think there's too much additional a11y affordance needed for a simple drop down menu, if we did need to make something custom. |
OK, I think I have a way to keep using details. It requires duplicating the |
OK I quickly glanced where it is attached:
and it doesn't require the heading per-se. What about about leaving that h2.c-sub-navigation-title alone, instead adding a new helper element below it only serving to attach the details on mobile instead?
to separate the h2 and title link from the details target (that can possibly be created by the JS as needed for smaller viewports?) |
This is kind of what I'm already suggesting (but not generating the new element on the fly), but we're now nit-picking on semantics. I think on mobile, it should probably still be an Edit: hmm, but it would be nice to still have the original h2 link accessible on mobile (which is something that is not possible right now even in prod). Perhaps this is something I can construct in a better way. |
Sorry, I haven't really tried changing it around to see how complicated it might be, this was just thinking aloud without any PoC at hand. The idea was to keep the h2 serving its purpose on all viewports, and only construct the details-expanding-element-target somehow "around" (=below?) that existing hitzone. (Oversimplification: Left side h2: anchor, right side / remaining white space, basically the expand chevron affordance and then what's left in the space: the target for the details.) That's basically what the current invalid markup does anyways. (I'm able to hit both the chevron and space around h2, as well as the h2 itself correctly in webkit): trim.39D4CC16-4A3C-48D1-B3E2-AA0FF172D4B7.MOV |
Ah, I see what you were meaning, thanks! I'll see what i can do here, but i also don't want to snowball this solution into something a lot more complicated. These sub nav menus will likely be overhauled over the coming year anyhow. |
Ah, and I was thinking this interaction fix could have been the last thing needed before upstreaming that component to Protocol, that's why the extra 👀 eyes;) I wouldn't bother anyone otherwise. |
No worries, I appreciate the thoughts and ideas! |
@janbrasna I think I have something workable based on your suggestion, and i also managed to find a pre-translated string suitable for the toggle 🤞 |
Lovely! Will try it out in a bit… I never realised it would be more block elements taking up the same space so some kind of display mode trickery might be needed to accommodate for both hitzones overlapping… (but I never doubted you'd find a solution without too much extra markup, not for a second!;)) Q: Actually, maybe a completely wrong idea — could the extra element be added just in a before/after pseudo or it needs more specific targeting for the JS hooks than that? (EDIT: Ah okay it has a ftl translation inside anyways, nevermind…) Praise: Thanks for converting all the submenus to the macro, I had it on my wishlist for some time too;) |
Description
On mobile viewports, the sub navigation dropdown heading consists of two nested, interactive components (a link inside a button). This can cause issues for assisted technologies, and could also technically produce unexpected results in some browsers, since it's invalid HTML.
Steps to reproduce
Expected result
There should only be one interactive component.
Actual result
Environment
N/A
The text was updated successfully, but these errors were encountered: