Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

ios keyborad jumps down and up #174

Open
dimitrisTheof opened this issue Mar 2, 2016 · 3 comments
Open

ios keyborad jumps down and up #174

dimitrisTheof opened this issue Mar 2, 2016 · 3 comments

Comments

@dimitrisTheof
Copy link

I am using ionic-plugin-keyboard and I am working on a chat application. I am using the following code in my controller:

.controller('ChatDetailCtrl', function ($scope, $stateParams, $ionicScrollDelegate, $interval, Chats, $rootScope, $timeout) {

//receive message
$scope.$on('onRepeatLast', function (scope, element, attrs) {
    var viewScroll = $ionicScrollDelegate.$getByHandle('userMessageScroll');
    keepKeyboardOpen();
    viewScroll.scrollBottom(true);
    keepKeyboardOpen();
});

//send message
$scope.sendMessage = function () {

        keepKeyboardOpen();
        viewScroll.scrollBottom(true);
        keepKeyboardOpen();

    }

function keepKeyboardOpen() {

    if (txtInput !== undefined) {
        txtInput.one('blur', function () {
            if(!IOS){
                window.cordova.plugins.Keyboard.show();
            }
            txtInput[0].focus();
        });
    }
}

})

Also I am using the directive:
.directive('onLastRepeat', function () {

    return function (scope, element, attrs) {
        if (scope.$last) setTimeout(function () {
            scope.$emit('onRepeatLast', element, attrs);
        }, 1);
    };
})

on config xml I am using:

on $ionicPlatform.ready I am using:
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}

On android platform everything is ok for both cases(send-receive message).
On ios platform send has normal behaviour but on receive message my keyborad jumps down and up again.
This happens after (viewScroll.scrollBottom(true);)
I want my keyboard stable and on receive message and just scrolling to the bottom like andoid.
I know that window.cordova.plugins.Keyboard.show(); uses only for andtoid platform.
What is going on? Can you please help me?

@NoahYarian
Copy link

if (txtInput !== undefined) {

txtInput.one('blur', function () {

  • This wouldn't be doing anything anyways because of .one instead of .on
  • You don't need if(!IOS){ if you don't want it. It only shows a log-

- (void) show:(CDVInvokedUrlCommand*)command { NSLog(@"Showing keyboard not supported in iOS due to platform limitations."); }

I'm still pretty new to all this so I don't have any deep insight on the pitfalls of what you're trying.
A few things do come to mind:

  • I was logging the window height when working on a directive and I saw weird values periodically. A thought on dealing with that was to check for more than one event with the same value before acting on it.
  • Seeing your template html would be helpful.
  • There's an on-scroll attribute you can set on ion-scroll elements also, so I'd try that route too if you're using them, or look at what that directive does.
  • Maybe try a timeout longer than 1ms. I'd try 50 or 400 and see if it changes anything.

Hopefully it's just your typo. Cheers

@nwocykra
Copy link

nwocykra commented Apr 24, 2016

This issue can usually be fixed by adding:
<script> window.cordova = {} </script>
to your index.html before any other script tags.

However, as i have discovered, it breaks cordova-plugin-inappbrowser.

Unfortunately this issue is so inconsistent that nobody is fixing it.

For reference: ionic-team/ionic-framework#5489 (comment)

@avoidwork
Copy link

Hi,

So this issue is compounded slightly with Okta as an authentication provider for a TFA / SSO workflow. Enabling the accessory bar to get a 'Done' option on iOS is working fine, but the screen is scrolling and the method to disable it doesn't affect the UI:

screen shot 2016-09-26 at 12 45 35 pm

screen shot 2016-09-26 at 12 45 39 pm

It's not a show stopper for me, but the inconsistent behavior is unfortunate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants