Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Focused radio buttons don't submit form on Enter #577

Closed
mlibby opened this issue Nov 8, 2014 · 2 comments
Closed

Focused radio buttons don't submit form on Enter #577

mlibby opened this issue Nov 8, 2014 · 2 comments
Assignees
Milestone

Comments

@mlibby
Copy link
Contributor

mlibby commented Nov 8, 2014

To reproduce:
Construct a <form> with md-radio-group any positive number of md-radio-button elements and a submit button.
Use the keyboard to focus the radio button group.
Press Enter.
Notice that the submit button is not activated.

Expected result:
The submit button should be activated.

Rationale:
Typical user agent behavior for forms is that pressing Enter while focused on a form element triggers an "implicit" submit (activate the submit button, if one is available). This is the behavior of the native control in Firefox and Chrome. http://www.w3.org/TR/html5/forms.html#implicit-submission

@marcysutton marcysutton reopened this Nov 10, 2014
@marcysutton marcysutton self-assigned this Nov 10, 2014
@ThomasBurleson ThomasBurleson modified the milestones: 0.9.0-rc1, 0.6.0-rc1, 0.7.0-rc1 Nov 13, 2014
@marcysutton
Copy link
Contributor

Confirmed this behavior: http://codepen.io/marcysutton/pen/GgqQqQ

marcysutton pushed a commit that referenced this issue Dec 19, 2014
marcysutton pushed a commit that referenced this issue Dec 19, 2014
@ajoslin ajoslin added the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Dec 19, 2014
marcysutton pushed a commit that referenced this issue Dec 19, 2014
@marcysutton marcysutton added resolution: fixed and removed in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs labels Jan 5, 2015
marcysutton pushed a commit that referenced this issue Jan 7, 2015
marcysutton pushed a commit that referenced this issue Jan 8, 2015
@mh03r932
Copy link

mh03r932 commented Feb 13, 2017

I think there is still a problem with md-radio-groups and form submission.

When there is no ng-submit handler configured directly on the form but there is a button with type=submit then the angular specification says that the click handler of the first type="submit" button should be triggered when pressing enter (see https://docs.angularjs.org/api/ng/directive/form section "Submitting a form and preventing the default action").

This works for normal input elements but not for md-radio-buttons.

JS Fiddle to demonstrate the issue:
http://jsfiddle.net/hh5xh7gf/

  1. focus radio-button
  2. press enter

Maybe this issue could be reopend?

I think in radioButton.js the keydownListener() function should be appended by something along the following lines
let formElement: IAugmentedJQuery = angular.element(this.$mdUtil.getClosest(element[0], 'form')); nextButtons = formElement.children().find('input[type="submit"], button[type="submit"]'); if(nextButtons){ nextButtons.first().click(); }

in the KEY_DOWN_ENTER case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants