Skip to content
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

Make header toolbar dropdown menu accessible #5897

Merged
merged 1 commit into from Dec 10, 2023

Conversation

foxbunny
Copy link
Collaborator

This patch makes the following changes:

  • Implements a new <ind-menu> custom element that is used to add necessary aria-* attributes to a combination of <button> and <menu> in the tollbar menu
  • Adds two folders, client/{js,styles}/custom-elements, that will be used to house Indico custom elements
  • Includes the ind-menu module in client/js/index.js
  • Restyles the toolbar menu to allow buttons to be used as menu items

See #5896

This PR requires the #5895 to be merged

CHANGES.rst Outdated Show resolved Hide resolved
@foxbunny foxbunny force-pushed the nav-toolbar branch 2 times, most recently from 415df9b to 73cf794 Compare September 22, 2023 07:56
@foxbunny
Copy link
Collaborator Author

foxbunny commented Sep 22, 2023

Rebased only the relevant changes on top of master, and also addressed code style issues discussed elsewhere.

@foxbunny
Copy link
Collaborator Author

foxbunny commented Oct 2, 2023

Rebased on master, updated folder structure to match previous PRs.

@ThiefMaster
Copy link
Member

I rebased it to the latest master and cleaned up some merge problems in the changelog.

The one thing I'm missing a bit in the new version is the little arrow indicating that a top menu item opens a submenu:

image
image

Also, can we avoid this little bit of white spacing between the main menu and its submenu?

Comment on lines 17 to 19
* {
box-sizing: border-box;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is no longer needed since you added it globally in a previous PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to clean this up later once I get done with category display page. Still have some issues to address there. But yeah, I'll remove this once I get it it.

@@ -11,26 +11,63 @@

/* Styles for the main menu */

.toolbar.global-menu {
@include font-family-title-light();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for removing this (which changes the font? If it needs to be larger fine, but new font looks strange there.

I tried adding it back locally, and IMHO it looks better (master vs your PR + this line added back):

image
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea is to first bring all styling under the DS, and then improve the design afterwards.

but new font looks strange there.

It's not the new font. It's just inheriting it from one of the ancestors. I want to flush out SUI first before I address font-related stuff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just prefer to have a "FIXME" / "remove later" with a 'hardcoded' font in here when merging it, instead of having it "broken" in master for some time and only change to the proper font in a later PR

(we already use 3.3/master in production on a smaller instance and I don't want to give them the surprise of a "strange" font change once i deploy the latest master there)

Copy link
Collaborator Author

@foxbunny foxbunny Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I should note that Roboto Light is most certainly not the appropriate font for this use case. In fact, any "Light" font is not a good use case for normal size text (and below) in general. You may use it on larger headings, but that's a different use case. Not all font rendering engines are made the same, and light fonts generally tend to render poorly on anything that isn't a Mac.

All in all we'll need to address the font choices anyway at some point. My long-term plan after the migration to DS is complete is to pick a good font set that works well across the board in terms of readability, licensing, and also from the aesthetic perspective.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but IMHO those "more invasive" changes are better to keep for later since we can do all the nice improvements at first without exposing users to big "oh wth why does this look completely different now?!?!" surprises :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"oh wth why does this look completely different now?!?!"

This is called a "canoe" problem. It's a temporary distraction that does not have no serious impact on usability. We generally shouldn't upgrade canoe problems into serious failures. ;)

indico/web/client/js/custom_elements/ind_menu.js Outdated Show resolved Hide resolved
});
});

this.addEventListener('keydown', function(ev) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evt

trigger.setAttribute('aria-expanded', trigger.getAttribute('aria-expanded') !== 'true');
});

this.addEventListener('focusout', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I prefer arrow functions for callbacks (also the ones above/below), but this one is interesting because of the this semantics.

I think in terms of readability and maintainability (I actually had to double-check the docs how this is used by addEventListener) it might be better to just use arrows and put a more explicit const elem = evt.target; (or .currentTarget) inside the callback.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I prefer arrow functions for callbacks

Sure. I've switched to arrows in newer PRs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to update it in here as well :)

@foxbunny foxbunny marked this pull request as draft October 17, 2023 13:07
@foxbunny
Copy link
Collaborator Author

foxbunny commented Nov 8, 2023

@ThiefMaster Where does this tool tip come from? Tried searching the exact text but nothing shows up.

image

@ThiefMaster
Copy link
Member

you find it when searching for event-type-tooltip-lecture

@foxbunny
Copy link
Collaborator Author

foxbunny commented Nov 8, 2023

Ugh, more jQuery :D


import {TipBase} from 'indico/custom_elements/TipBase';

const tipDelay = 1000; // ms
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels too slow. What about using something around 100-250ms? (I tested it and it feels way more reactive that way)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there's this:

image

But then again, many authors use about .5s delay instead.

So not sure what is "typical" really. At any rate, 100~250 is way too low. This delay is used to minimize distraction while tabbing through the interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fair enough. 500ms feels fine as well.

(If we ever move the event creation dialog to react I could absolutely see the button to just become "Create event" and the type selection going in the dialog itself instad of being nested in a dropdown)

trigger.setAttribute('aria-expanded', trigger.getAttribute('aria-expanded') !== 'true');
});

this.addEventListener('focusout', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to update it in here as well :)

@ThiefMaster
Copy link
Member

image

Can we avoid this one-pixel gap between the menu and the expanded dropdown?

@ThiefMaster
Copy link
Member

image

Would it be possible to open the tooltip to the right instead of to the top? For the first dropdown item it doesn't matter, but right now it's pretty much impossible to create a lecture after hovering meeting/conference - you have to move the mouse pointer outside the dropdown first so the tooltip closes, since it covers the dropdown entries above.

@ThiefMaster
Copy link
Member

ThiefMaster commented Dec 6, 2023

Is the very dark gray (#333) of the menu bar required for contrast or would something slightly brighter such as #444 or #555 (the previous color) still have strong enough contrast (especially since the text is a bit larger now than it was before - which in this particular place actually looks better than it looked before with the smaller text IMHO ;))?

@foxbunny
Copy link
Collaborator Author

foxbunny commented Dec 6, 2023

Is the very dark gray (#333) of the menu bar required for contrast or would something slightly brighter such as #444 or #555 (the previous color) still have strong enough contrast

As far as grays go, I think the cut-off is #737373. So yeah, we can use that. Should make for better contrast with the tooltip, too.

let viewportWidth = document.documentElement.clientWidth;
let viewportHeight = document.documentElement.clientHeight;

window.addEventListener('DOMContentLoaded', () => requestIdleCallback(updateClientGeometry));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domReady.then(...);?

const refCenter = `${referenceRect.x + referenceRect.width / 2}px`;
let arrowBorder;

console.log(referenceRect);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove that ;)

'The <menu> element must come after <button>'
);

trigger.setAttribute('aria-expanded', false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be 'false' since AFAIK DOM attributes are always strings? (even though the false is probably implicitly converted to a string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's always converted to string, and that is negligible performance hit too, so you'd just waste two characters to be pedantic. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking because you (correctly) check for !== 'true' below and I could already see a less experienced developer checking for === false for whatever reason (after all, it's set to false!) and wondering why it doesn't work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, what would it take for them to learn how coercion works in JavaScript?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Explicit is better than implicit." (even though that's from the zen of python and we have javascript here ;))

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another saying: 'When in Rome, do as the Romans do.' This is JavaScript. Coercion is everywhere. You're not escaping that. Gotta learn at some point.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a super strong opinion on keeping/changing it so I'll leave it up to you

@ThiefMaster
Copy link
Member

As far as grays go, I think the cut-off is #737373

I propose sticking with #555 then (that's our default $black [not commenting on whether or not it makes sense to call a dark gray "black" ;)] in the palette) :)

@foxbunny foxbunny marked this pull request as ready for review December 7, 2023 08:12
@foxbunny
Copy link
Collaborator Author

foxbunny commented Dec 7, 2023

@ThiefMaster I think I got everything. Let me know if there's anything else.


ind-with-tooltip,
ind-with-toggletip {
--tooltip-surface-color: #000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it cause any a11y problems if we changed this to #333? Feels a bit very dark right now.

image
image

(Might also be personal preference, but for anything dark-mode-related I generally prefer the "dim" version over the "full black background" version, and I guess this also applies here even if it's just a tooltip)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the tooltip, I would leave it as is, because we cannot predict what ends up behind it. This way, we make sure it stands out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least right now we don't have anything darker than the menus and the meeting page background....

(so far the preference within the team is on the #333 version btw)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we can always change it. I'm currently on the road. I'll get back to this later in the afternoon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed

@ThiefMaster ThiefMaster changed the base branch from master to a11y December 10, 2023 23:11
- Correctly indicate the roles and states of the dropdown menu
- Use a vanilla JavaScript implementation of the dropdown
- Introduce new folders `client/{js,styles}/custom-elements`
- Improve accessibility of the tooltips for the #create-* buttons
@ThiefMaster ThiefMaster enabled auto-merge (squash) December 10, 2023 23:14
@ThiefMaster ThiefMaster merged commit 003267c into indico:a11y Dec 10, 2023
10 checks passed
@ThiefMaster ThiefMaster added this to the v3.3 milestone Dec 10, 2023
ThiefMaster pushed a commit that referenced this pull request Jan 4, 2024
- Correctly indicate the roles and states of the dropdown menu
- Use a vanilla JavaScript implementation of the dropdown
- Improve accessibility of the tooltips for the #create-* buttons
ThiefMaster pushed a commit that referenced this pull request Jan 4, 2024
- Correctly indicate the roles and states of the dropdown menu
- Use a vanilla JavaScript implementation of the dropdown
- Improve accessibility of the tooltips for the #create-* buttons
ThiefMaster pushed a commit that referenced this pull request Jan 19, 2024
- Correctly indicate the roles and states of the dropdown menu
- Use a vanilla JavaScript implementation of the dropdown
- Improve accessibility of the tooltips for the #create-* buttons
ThiefMaster pushed a commit that referenced this pull request Jan 26, 2024
- Correctly indicate the roles and states of the dropdown menu
- Use a vanilla JavaScript implementation of the dropdown
- Improve accessibility of the tooltips for the #create-* buttons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants