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

Menus open on form submit #848

Closed
jamess-ais opened this issue Jan 18, 2023 · 1 comment
Closed

Menus open on form submit #848

jamess-ais opened this issue Jan 18, 2023 · 1 comment
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@jamess-ais
Copy link

Current Behavior

While using the use:menu system in a form I noticed that if I clicked enter in the input it would open the menu also in the form.

Steps To Reproduce

  1. Create a form with an input and a menu in it
  2. Input type is type="search"
  3. Click enter in the input and it should do on:submit. It should also open the menu (but I assume it shouldn't)

Anything else?

A hacky work around is the following on the input;
on:keydown={key => {if(key.key === "Enter") {key.preventDefault(); onSubmit();}}}

When the Enter key is pressed in the input it'll prevent default which creates some on submit event which the use:menu is triggered by (I assume). We then call whatever function you would've defined in the form's on:submit

@jamess-ais jamess-ais added the bug Something isn't working label Jan 18, 2023
@endigo9740
Copy link
Contributor

Hey @jamess-ais I've now had a moment to understand the issue here. This is actually working as intended. The ARIA APG sets the guidelines for what keyboard shortcuts should be implemented per each element. See the following for menus.

NOTE: we link to this at the top of the Menus doc for future reference.

https://www.w3.org/WAI/ARIA/apg/patterns/menu/

Screen Shot 2023-01-19 at 2 38 11 PM

By changing or removing this behavior we would actually be damaging accessibility for this feature. For now I'd say your work around is probably the best solution if you wish to keep things setup as is.

Alternatively, a better solution might be to avoid using Menu + Inputs in this manner. Note we do have an Auto-complete feature in the works that may be a proper replacement for you soon, but this is not yet available.

As a temporary solution, you can also look into the native browser solution using datalists. It's not as uniform in style across browsers, but might get you by for now:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/datalist

@endigo9740 endigo9740 added the wontfix This will not be worked on label Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants