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

Add keyboard shortcut to submit forms #11990

Merged
merged 3 commits into from
Jan 9, 2024

Conversation

dacook
Copy link
Member

@dacook dacook commented Dec 29, 2023

What? Why?

Although enter will submit the form in many cases, it doesn't cover elements such as textarea.

Power users of web apps would be familiar with the keyboard shortcut for submitting forms:
ctrl+enter ( or cmd+enter for macOS). Refer: https://ux.stackexchange.com/a/136590/36009

This will enable power users to submit standard forms quicker. Unfortunately I couldn't get it to work for Angular forms which are widespread, so the benefit is reduced. If anyone knows how to do that, it would be nice..

Note that the web "standard" of accesskey is not accepted as a solution for this, hence the need for Javascript (see https://webaim.org/techniques/keyboard/accesskey).

What should we test?

Submit some forms in frontend and backend. For example:

  • log in
  • checkout, and press ctrl+enter for comments:
    Screenshot 2023-12-29 at 3 00 25 pm

Admin

  • Try pressing it in Enterprise edit screen: nothing happens (like before)
  • Edit product description
    Screenshot 2023-12-29 at 3 15 00 pm

Release notes

It's probably not worth mentioning as a user-facing change unless we can implement it for all (angular) forms.

Changelog Category (reviewers may add a label for the release notes):

  • User facing changes
  • API changes (V0, V1, DFC or Webhook)
  • Technical changes only
  • Feature toggled

The title of the pull request will be included in the release notes.

Dependencies

Documentation updates

Unfortunately it doesn't work for Angular forms. I'm not sure if there's a way to trigger an angular submit.
@dacook dacook self-assigned this Dec 29, 2023
Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

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

Thanks ! I hate when I can't use usual keyboard shortcut on a website.

@drummer83 drummer83 self-assigned this Jan 9, 2024
@drummer83 drummer83 added the pr-staged-au staging.openfoodnetwork.org.au label Jan 9, 2024
@drummer83
Copy link
Contributor

Hi @dacook,
Cool! Thank you for improving this!

I couldn't find any problems with it. Great! 🥳
Merging! 🚀

@drummer83 drummer83 merged commit 1e2985b into openfoodfoundation:master Jan 9, 2024
52 checks passed
@drummer83 drummer83 removed the pr-staged-au staging.openfoodnetwork.org.au label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants