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

gesture: Angular Material breaks form ng-submit via enter/go button on iOS #3990

Closed
wlingke opened this issue Aug 2, 2015 · 29 comments · Fixed by #10189
Closed

gesture: Angular Material breaks form ng-submit via enter/go button on iOS #3990

wlingke opened this issue Aug 2, 2015 · 29 comments · Fixed by #10189
Labels
- Lots of Comments for: internal contributor The team will address this issue and community PRs are not requested. has: Pull Request A PR has been created to address this issue P1: urgent Urgent issues that should be addressed in the next minor or patch release. resolution: fixed type: bug type: gestures ux: integration
Milestone

Comments

@wlingke
Copy link

wlingke commented Aug 2, 2015

If you have a form with ng-submit, pressing enter on a iOS device (with both chrome and safari), will not trigger the ng-submit function. This works as expected with angularjs alone but with the addition of angular material, it no longer works.

Working (without ngMaterial)
http://embed.plnkr.co/Cs3QTjaN6GdnfL1vOKNl/preview

Not working (with ngMaterial)
http://embed.plnkr.co/F0qVeaIxNnBlLHgVKQ5Z/preview

@julienpa
Copy link

I think I have the same issue when trying to submit a form with Angular (1.4.3) and Angular Material (0.10.1) by pressing enter: the ng-submit is not triggered, whereas it works well when there is a simple md-button inside the form

@ThomasBurleson ThomasBurleson added this to the 0.12.0 milestone Sep 1, 2015
@ThomasBurleson ThomasBurleson added for: internal contributor The team will address this issue and community PRs are not requested. ux: integration labels Sep 1, 2015
@topherfangio topherfangio added needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community priority: medium labels Sep 4, 2015
@mackelito
Copy link

+1..
Same issue here, using angular 1.4.5, Materials 0.10.1

@topherfangio topherfangio modified the milestones: 0.12, 0.13 Oct 15, 2015
@aogut
Copy link

aogut commented Oct 26, 2015

+1
it worked for me on 0.11.2 but broke on 1.0

@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc2, 1.0-rc3 Oct 30, 2015
@jamalx31
Copy link

jamalx31 commented Nov 1, 2015

+1

@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc3, 1.0-rc4 Nov 7, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc4, 1.0-rc5 Nov 16, 2015
@tonyawad88
Copy link

+1

@topherfangio
Copy link
Contributor

I definitely see the issue within the Plunkr; however, when I extracted it into a simple HTML file on my own iPad to reproduce, the issue disappears. I am running iOS 9, so perhaps that is part of the difference?

Note that the Plunkr fails on Chrome on desktop as well as iOS.

Can someone double-check my code below and let me know if there is something specific you are doing to reproduce, or if it's only a particular version of iOS, because it appears to be working to me?

P.S. I've added a comment for testing against master as well to see if it was fixed, but I can't reproduce with either of them loaded.

<!doctype html>
<html>
  <head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material/0.10.0/angular-material.js"></script>
    <!--
    <script src="https://material.angularjs.org/HEAD/angular-material.min.js"></script>
    //-->
  </head>

  <body ng-app="app">
    <div ng-controller="Ctrl">

      <form name="testForm" ng-submit="submit(test)">
        <input type="text" ng-model="test">
        <input type="submit">
      </form>

    </div>

    <script typ="text/javascript">
      angular.module('app', ['ngAnimate'])
      .controller('Ctrl', function Ctrl($scope) {
        $scope.submit = function(value){
          alert(value)
        }
      })
    </script>
  </body>
</html>

@topherfangio topherfangio added this to the 1.0-rc6 milestone Nov 23, 2015
@linslin
Copy link

linslin commented Mar 4, 2016

+1

3 similar comments
@reppners
Copy link

reppners commented Mar 8, 2016

+1

@mseemann-imatics
Copy link

+1

@maenthoven
Copy link

+1

@vikasgulati
Copy link

type="submit" worked for me on Mac OSX (Chrome).

@rcheuk
Copy link

rcheuk commented Apr 15, 2016

+1

@cjardmore
Copy link

cjardmore commented May 3, 2016

This may help some who are following this thread. It appears the plunkr provided by @mjaverto has an 'action' property defined, which appears to break the submit functionality wrapped into the ngForm directive. Around line 21916 of angular.js (I'm looking at v1.5.5).

@cjardmore
Copy link

cjardmore commented May 3, 2016

It appears this issue may be linked to ios keyboard not firing 'submit' event when 'Enter' key is pressed.

Without additional meditation / testing I can't say I can suggest an approach to solving this.

Just in case my comments are not relevant to all issues here, here's a little about my env / issue. I'm debugging an Apache Cordova app. The behavior I'm trying to achieve is for the 'Enter' key on ios keyboard to submit the form regardless of which input field within the form the cursor is focused on.

Running v1.5.5 angular v1.0.7 material, ios 9.3.1, cordova 6.1.1, cordova-plugin-crosswalk-webview 1.6.1

@cjardmore
Copy link

What I've decided I need to do for the time being is provide 2 different "submit" options. One 'path' is looking for a 'keyup' event if it's an ios device. The other is falling back to the normal form submit functionality. As a precaution, I'm excluding ios devices from the normal submit action to prevent double-submit on ios devices in case a future update fixes this behavior.

The above change required me to add an 'ng-click' event to any buttons that were intended to submit the form. Again, for all possible actions to submit the form I'm detecting the device (via cordova's device plugin, which provides a 'platform' attribute) to ensure that one path is ios devices only, and the other path is everyone else.

NOTE: For regular web apps the device detection mentioned above may not be as straightforward or reliable. In Apache Cordova window.device.platform will equal the exact string 'ios', 'android', etc depending on the device the app is running in.

@ThomasBurleson
Copy link
Contributor

This issue is closed as part of our ‘Surge Focus on Material 2' efforts.
For details, see our forum posting @ http://bit.ly/1UhZyWs.

radotzki added a commit to radotzki/material that referenced this issue Dec 28, 2016
@ThomasBurleson ThomasBurleson added the has: Pull Request A PR has been created to address this issue label Mar 7, 2017
@ThomasBurleson ThomasBurleson reopened this Mar 7, 2017
@Splaktar Splaktar modified the milestones: Deprecated, 1.1.4 May 18, 2019
@Splaktar Splaktar changed the title Angular Material breaks form ng-submit via enter/go button on iOS gesture: Angular Material breaks form ng-submit via enter/go button on iOS May 18, 2019
@Splaktar Splaktar added type: gestures and removed needs: investigation The cause of this issue is not well understood and needs to be investigated by the team or community labels May 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
- Lots of Comments for: internal contributor The team will address this issue and community PRs are not requested. has: Pull Request A PR has been created to address this issue P1: urgent Urgent issues that should be addressed in the next minor or patch release. resolution: fixed type: bug type: gestures ux: integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.