material icon indicating copy to clipboard operation
material copied to clipboard

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

Open wlingke opened this issue 11 years ago • 29 comments

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

wlingke avatar Aug 02 '15 22:08 wlingke

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

julienpa avatar Aug 14 '15 17:08 julienpa

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

mackelito avatar Sep 30 '15 12:09 mackelito

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

aogut avatar Oct 26 '15 22:10 aogut

+1

jamalx31 avatar Nov 01 '15 13:11 jamalx31

+1

tonyawad88 avatar Nov 17 '15 21:11 tonyawad88

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 avatar Nov 23 '15 16:11 topherfangio

+1 same problem here:

iOS 9.1 (13B143) on an iPhone 5 (Model A1429)

mjaverto avatar Nov 23 '15 16:11 mjaverto

Also problem in iOS Simulator for iPhone 6, iOS 9.1 (13B137)

"angular-material": "v1.0.0-rc4"

Confirmed working in 0.11.2 but tons of other issues came up when we downgrade there.

mjaverto avatar Nov 23 '15 16:11 mjaverto

+1 seeing same issue as @mjaverto

rjdavis3 avatar Nov 23 '15 17:11 rjdavis3

@mjaverto @rjdavis3 Can one of you please provide a simple HTML example like above (i.e. not a Codepen/Plunkr) that demonstrates this? As I said, I am unable to reproduce and need a little bit of help seeing exactly what code makes it break.

Thanks!

topherfangio avatar Nov 23 '15 17:11 topherfangio

@topherfangio sure. I know this is a plunkr but just copy the HTML out easily.

http://plnkr.co/edit/miCYIujo5vwNH0PgbJOE?p=preview

I just loaded this in an iOS iPhone 6 simulator running 9.1 to confirm. I should also note, the above does work on 0.11.2.

mjaverto avatar Nov 24 '15 13:11 mjaverto

Thanks! I can confirm and will look into it.

topherfangio avatar Nov 24 '15 16:11 topherfangio

It doesn't appear this was fixed in a 1.0 release candidate. I'm experiencing this problem with the latest version, on Windows 10 desktop chrome version 47.0.2526.106 m.

lewiswharf avatar Dec 30 '15 21:12 lewiswharf

@lewiswharf Indeed, this is still an open issue on our radar.

topherfangio avatar Dec 30 '15 22:12 topherfangio

add type="submit" to your md-button and it worked for me

chrishawn avatar Jan 08 '16 20:01 chrishawn

Indeed, with type="submit" and the button inside the <form> element, it works for me too

julienpa avatar Jan 09 '16 17:01 julienpa

type="submit" worked! Seems logical.

lewiswharf avatar Jan 10 '16 01:01 lewiswharf

adding type="submit" did not help me. iOS 9.2 AngularMaterial 11.2.

Working (with 1 input):

    <form ng-submit="login()">
          <md-input-container>
            <label>Email</label>
            <input ng-model="user.email" type="email" >
          </md-input-container>
        </form>

Not Working:

    <form ng-submit="login()">
        <md-input-container>
            <label>Email</label>
            <input ng-model="user.email" type="email" >
        </md-input-container>

        <md-input-container>
          <label>Password</label>
          <input ng-model="user.password" type="password">
        </md-input-container>
      </form>

temporary Solution:

<input ng-model="user.password" type="password"  ng-keypress="keyPressed($event)">
    $scope.keyPressed = function(keyEvent) {
      if (keyEvent.keyCode === 13) {
        cordova.plugins.Keyboard.close();
      }
    };

jfbloom22 avatar Jan 28 '16 14:01 jfbloom22

+1

oh-wo avatar Feb 03 '16 08:02 oh-wo

+1

linslin avatar Mar 04 '16 16:03 linslin