ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: scrollBottom() removes focus on input or textareas

Open fkukuck opened this issue 11 years ago • 8 comments

Type: bug

Platform: all

When $ionicScrollDelegate.scrollBottom() and .scrollTop() are fired when an input or textarea field is focused, the focus is lost! This behavior is new to beta 14. See this codepen for the issue: http://codepen.io/tsurrel/pen/myRmbe Just type in something in the input field and see how focus is lost, because .scrollBottom() is called. Then replace the beta 14 by beta 13 and see how focus is kept (this should be the intended behavior). Thank you for fixing.

fkukuck avatar Jan 09 '15 09:01 fkukuck

just rebult the function remove ..blurall andfix it

ckken avatar Jan 09 '15 21:01 ckken

Removing blurall works. So this is actually intended... Sorry for compaining then.

fkukuck avatar Jan 10 '15 18:01 fkukuck

@clawish this is intended behavior? I feel like input blurring should not be a concern of the scroll delegate. In my case, I do NOT want inputs to blur on scrolling.

cquartier avatar Jan 10 '15 22:01 cquartier

@clawish can you please share solution using a codepen?

pulakb avatar Jan 13 '15 08:01 pulakb

in the ionic.bundle.js change the lines

self.scrollTop = function(shouldAnimate) {
    ionic.DomUtil.blurAll();
    self.resize().then(function() {
        scrollView.scrollTo(0, 0, !!shouldAnimate);
    });
};

self.scrollBottom = function(shouldAnimate) {
    ionic.DomUtil.blurAll();
    self.resize().then(function() {
        var max = scrollView.getScrollMax();
        scrollView.scrollTo(max.left, max.top, !!shouldAnimate);
    });
};

to

self.scrollTop = function(shouldAnimate) {
    //ionic.DomUtil.blurAll();
    self.resize().then(function() {
        scrollView.scrollTo(0, 0, !!shouldAnimate);
    });
};

self.scrollBottom = function(shouldAnimate) {
    //ionic.DomUtil.blurAll();
    self.resize().then(function() {
        var max = scrollView.getScrollMax();
        scrollView.scrollTo(max.left, max.top, !!shouldAnimate);
    });
};

fkukuck avatar Jan 13 '15 09:01 fkukuck

I suggest to add a variable to avoid the blurring, instead of commenting out:

   self.scrollTop = function(shouldAnimate, avoidBlur) {
    if (avoidBlur !== true){
      ionic.DomUtil.blurAll();
    }
    self.resize().then(function() {
      scrollView.scrollTo(0, 0, !!shouldAnimate);
    });
  };

panurge-ws avatar Jan 23 '15 14:01 panurge-ws

@panurge-ws nice solution! Would you be so kind and create a pull request? Until now, the "bug" is still in the code.

osahner avatar Feb 03 '15 08:02 osahner

Could be closed: 0145dc3

osahner avatar Feb 08 '15 16:02 osahner