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

Up/Down arrow keys not working on dropdown #2933

Open
mohitbalwani opened this issue Jan 20, 2024 · 10 comments · May be fixed by #3320
Open

Up/Down arrow keys not working on dropdown #2933

mohitbalwani opened this issue Jan 20, 2024 · 10 comments · May be fixed by #3320
Labels
Area:Accessibility Category for accessibility related features and bugs Enhancement

Comments

@mohitbalwani
Copy link
Contributor

p5.js version

No response

What is your operating system?

Mac OS

Web browser and version

No response

Actual Behavior

Up/Down arrow keys are not working on dropdown items.

Expected Behavior

We should be able to navigate through dropdown items using up/down arrow keys.

Steps to reproduce

Steps:

  1. Go to https://editor.p5js.org
  2. Click on File from menu
  3. Press tab to move focus to the dropdown.
  4. Use up/down arrow keys to navigate the dropdown.
@mohitbalwani
Copy link
Contributor Author

@lindapaiste Initially, I attempted to add an event listener in the useEffect inside NavDropdownMenu.jsx, but it doesn't seem to be doing the trick. I noticed we already have useKeyDownHandlers utility in the codebase. Do you think it could be leveraged for this use case?

@PiyushThapaa
Copy link
Contributor

@mohitbalwani I think this not a bug but intentional
@raclim @lindapaiste what do you think about this?

@shoaib-31
Copy link

@mohitbalwani I also think it's intentional as we can move backward using Shift+Tab

@lindapaiste
Copy link
Collaborator

It's not a "bug" but it's a good feature request! Right now everything is navigable using the Tab key but I have wanted to support using arrow keys as a secondary method. There's a //TODO comment somewhere in the code about it. I think in one of the Drowdown components.

@mohitbalwani yes you should be able to make use of useKeyDownHandlers here.

We want the arrows to do nothing if the component is not focused. When a dropdown is expanded, you would be able to use the up and down arrows to move up or down the list of items. I'm not sure what's supposed to happen if you're on the last item of the list and then press the down arrow. Should it loop back around to the start? Close the dropdown? It would be good if we can find some relevant ARIA guidelines so we know how to handle every case.

@lindapaiste lindapaiste added Area:Accessibility Category for accessibility related features and bugs Enhancement and removed Bug labels Jan 22, 2024
@lindapaiste
Copy link
Collaborator

First things first, let's make sure that our HTML markup is as descriptive as possible. We want the browser to understand what these elements represent and how to interact with them. We might not need to use a lot of explicit event handling. I'm not sure if this section is describing behavior that's automatic? https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menu_role#keyboard_interactions

We want the menubar role on the main nav bar, menu on each dropdown, menuitem on each item, etc.

This should be the first course of action, before adding any event handlers.

@Prateek-Fst
Copy link

Prateek-Fst commented Jan 30, 2024

I would like to work on this issue my initial action will be starting with (Nav.jsx) p5.js-web-editor/client/modules/IDE/components/Header/Nav.jsx

And then changing the usage of ul and li tag with menu and menu item ,
I want to raise a PR on this issue what’s your opinion about this @lindapaiste , @mohitbalwani

@lindapaiste
Copy link
Collaborator

@Prateek-Fst I started working on the ARIA markup in a draft PR #2968 but I didn’t finish. You can fork that branch and address the “pending” items listed in that PR.

@tespin
Copy link
Contributor

tespin commented Jul 21, 2024

We want the arrows to do nothing if the component is not focused. When a dropdown is expanded, you would be able to use the up and down arrows to move up or down the list of items. I'm not sure what's supposed to happen if you're on the last item of the list and then press the down arrow. Should it loop back around to the start? Close the dropdown? It would be good if we can find some relevant ARIA guidelines so we know how to handle every case.

according to the recent ARIA authoring guide, wrapping from the last to first or vice versa is optional depending on the use case. I think that since it's a fairly small set of options in the dropdown menus, wrapping can make sense here. As far as I've learned, menus should only be closed via keyboard if focus is moved to a different item in the menubar or an option within a menu is activated (and if the esc key is pressed, of course).

I just finished adding ARIA markup a few days ago so I'm giving this issue some attention now, though if anyone else has already started working on it please chime in!

@IshinoAkuma
Copy link

@tes

menus should only be closed via keyboard if focus is moved to a different item in the menubar or an option within a menu is activated (and if the esc key is pressed, of course).

have you had a chance to work on this more? esc is not working for me on desktop windows 10 brave/chromium... it's frustrating :D

Probably important to note though, when I press escape the menu stays open and appears to lose focus, so the only way I can make it go away is to click somewhere else in code then put the cursor back where I was to continue typing. i.e. menu stays and keyboard input gets lost.

@tespin
Copy link
Contributor

tespin commented Jan 17, 2025

have you had a chance to work on this more? esc is not working for me on desktop windows 10 brave/chromium... it's frustrating :D

Probably important to note though, when I press escape the menu stays open and appears to lose focus, so the only way I can make it go away is to click somewhere else in code then put the cursor back where I was to continue typing. i.e. menu stays and keyboard input gets lost.

hi @IshinoAkuma , i just finished refactoring the component and am finalizing keyboard behaviors in #3320. thanks for noting the windows behavior, that looks very inconvenient and definitely not accessible! i'm hoping to be ready with the PR some time next week and will test the behaviors across devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Accessibility Category for accessibility related features and bugs Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants