Key board reopens when closing ionicPopup


#1

I’m having an issue in iOS where, if I open a pop-up and then close the native keyboard prior to closing the pop-up, the keyboard will re-open after the pop-up is dismissed. IS there any way to prevent this from happening?

Pop-up opens:

Click in the background and keyboard closes:

Click Cancel or Submit to dismiss pop-up and keyboard re-opens:


Keyboard reopens when closing popup
#2

Additionally, is there any way to prevent the keyboard from opening when the pop-up loads?


#3

i think if you click on the button the event is propagated to the input field in the background (search field). try to tap on the part of the cancel or submit button where there is no input field in the background for testing.

if its the reason do this:

var myPopup = $ionicPopup.show({
    templateUrl: '...',
    title: 'Resend ....',
    scope: $scope,
    buttons: [
      { 
        text: 'Cancel' 
        onTap: function(e) {
            // your code
            e.stopPropagation();
        }
      },
      {
        text: 'Save',
        type: 'button-positive',
        onTap: function(e) {
            // your code
            e.stopPropagation();
        }
      },
    ]
});

#4

Thanks. That does appear to be the issue. When I click on the part of either of the buttons that is not over the search field, then the click is not propagated and the keyboard does not open.

However, adding e.stopPropagation does not appear to fix the issue. Here is my popup setup with it added:

var emailPopup = $ionicPopup.show({
  template: '<input type="email" ng-model="user.email">',
  title: 'Resend Confirmation Email',
  scope: $rootScope,
  buttons: [
    { 
      text: 'Cancel',
      onTap: function(e) {
        e.stopPropagation();
      } 
    },
    {
      text: '<b>Submit</b>',
      type: 'button-positive',
      onTap: function(e) {
        if (!$rootScope.user.email) {
          var message = "Please enter an email address"
          console.log(message);
          navigator.notification.alert(message, null, 'Alert', 'OK');
          e.preventDefault();
        } else {
          e.stopPropagation();
          return $rootScope.user.email;
        }
      }
    },
  ]
});

I am still seeing the keyboard open after the pop-up closes if the keyboard was closed prior to clicking either the Cancel button or the Submit button.


#5

Might have something to do with the click lingering as noted in this post:


#6

Well the fix that worked in the linked issue will not work for me, because it disables the search input field.


#7

This will be fixed by commit #7faeeda that will be in v1.0.0-beta.11.