Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(checkbox): submit on enter rather than toggle #11584

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

codymikol
Copy link
Contributor

make enter keypress submit form rather than toggle checkbox

Fixes: #11583

PR Checklist

Please check that your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added or this is not a bug fix / enhancement
  • Docs have been added, updated, or were not required

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Enhancement
[ ] Documentation content changes
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Currently if you have a checkbox focused and press enter, you toggle the value of the checkbox.

Issue Number: #11583

What is the new behavior?

Now pressing enter while focusing a checkbox within a form, the form will be submitted. If no form exists, nothing will happen.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

N/A

@googlebot googlebot added the cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ label Jan 8, 2019
@Splaktar Splaktar added a11y This issue is related to accessibility P2: required Issues that must be fixed. labels Jan 9, 2019
@Splaktar Splaktar self-requested a review January 9, 2019 02:19
@Splaktar Splaktar self-assigned this Jan 9, 2019
@Splaktar Splaktar added this to the 1.1.13 milestone Jan 9, 2019
Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

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

A couple small nits and one question. Thank you for getting this PR posted so quickly (and for tests)!

src/components/checkbox/checkbox.js Outdated Show resolved Hide resolved
src/components/checkbox/checkbox.js Outdated Show resolved Hide resolved
src/components/checkbox/checkbox.js Show resolved Hide resolved
src/components/checkbox/checkbox.spec.js Outdated Show resolved Hide resolved
src/components/checkbox/checkbox.spec.js Outdated Show resolved Hide resolved
@Splaktar Splaktar added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Jan 9, 2019
make enter keypress submit form rather than toggle checkbox

Fixes: angular#11583
Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

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

LGTM

@Splaktar Splaktar added pr: merge ready This PR is ready for a caretaker to review pr: lgtm This PR has been approved by the reviewer and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Jan 15, 2019
@Splaktar Splaktar assigned mmalerba and unassigned andrewseguin Jan 29, 2019
@mmalerba mmalerba merged commit a191a8e into angular:master Feb 1, 2019
Splaktar added a commit that referenced this pull request Feb 1, 2019
mmalerba pushed a commit that referenced this pull request Feb 1, 2019
var form = $mdUtil.getClosest(ev.target, 'form');
// We have to use a native event here as the form directive does not use jqlite
if (form) {
form.dispatchEvent(new Event('submit'));
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this can possibly submit the form even when the button of type="submit" is disabled.

Copy link
Member

Choose a reason for hiding this comment

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

This seems to align with the native behavior where pressing enter in an input will submit the form even if the form has no button.

Copy link
Member

Choose a reason for hiding this comment

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

More investigation and follow up in #11639.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a11y This issue is related to accessibility cla: yes PR author has signed Google's CLA: https://opensource.google.com/docs/cla/ P2: required Issues that must be fixed. pr: lgtm This PR has been approved by the reviewer pr: merge ready This PR is ready for a caretaker to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

checkbox: enter should submit form and not toggle
6 participants