angular-confirm icon indicating copy to clipboard operation
angular-confirm copied to clipboard

Enter key doesn't work when modal contains an input with the cursor in it

Open jbernalvallejo opened this issue 7 years ago • 2 comments

It works for any other key or when input is not focus. However, when both situations occur simultaneously, enter action doesn't get triggered.

jbernalvallejo avatar Nov 22 '17 12:11 jbernalvallejo

Managed to fix the issue. As Angular already submits the form ng-submit function when pressing enter, I did a workaround to get this function calling the button action.

HTML in the modal template

 <form ng-submit="onSubmit()">
     <label>Name</label>
     <input type="text" ng-model="name"/>
</form>

JS modal config

},
onScopeReady: function(scope){
    // call button action when enter is pressed
    var self = this;
    scope.onSubmit = function () {
        self.buttons.confirm.action(scope);
    };
},
buttons: {
    confirm: {
      keys: ['enter'],
      action: function(scope) {
        // ...
        return;
      }
    }
}

jbernalvallejo avatar Nov 22 '17 17:11 jbernalvallejo

Thanks a lot for this

AquiburRKhan avatar Apr 18 '18 09:04 AquiburRKhan