Prevent autofocus on input in modal?


#1

I have a modal slide up and it contains some inputs. Unfortunately, the first one is autofocused causing the iOS keyboard to pop open. But it doesn’t function very well, so I’d like to disable the autofocus. How can I do that?

Thanks!


#2

Hey @jprichardson, I just changed the default on this to be false instead of true, since I agree it’s a bit wonky. Pull from master to see those changes. Here’s the commit: https://github.com/driftyco/ionic/commit/fbda047c1d13885e6ee589f3d78caafda5a680f1


#3

Perfect! I’m still using 0.9.10 because I’m scared to upgrade until the alpha of my app is completed and tests are in place. From your change, I learned that I could just do this:

Modal.fromTemplateUrl('modal.html', function(modal) {
  $scope.modal = modal
}, {focusFirstInput: false})

Thanks!


#4

Okay great. Just note that the version in master now has much better scrolling, so maybe that’ll be a reason to upgrade :slight_smile:


#5

has this been fixed? why i still have this problem with beta 4.
and, even I add the config like following, the keyboard still auto focus on my first input and the pop up.

$ionicModal.fromTemplateUrl(
    'modals/new_frontline.html', 
    function(modal){
        $scope.mdl_new_frontline = modal;
    },
    {
        scope: $scope,
        focusFirstInput: false,
        animation: 'slide-in-up'
    }
);