slackhq / SlackTextViewController

⛔️**DEPRECATED** ⛔️ A drop-in UIViewController subclass with a growing text input view and other useful messaging features
https://slack.com/
MIT License
8.32k stars 1.08k forks source link

Dismiss keyboard with pan gesture causing tableview to scroll to top (non-inverted mode) #321

Closed tylerjames closed 8 years ago

tylerjames commented 8 years ago

When scrolled to the bottom (non-inverted) if I bring up the keyboard by tapping the input bar the keyboard shows. Then if I try to dismiss the keyboard by using a pan gesture starting from above the text input bar the tableview will immediately be set to the very top position (the oldest message). It does not animate it just jumps all the way to the top.

This may be somehow associated with the fact that I'm using non-inverted mode, but I'm not sure.

tylerjames commented 8 years ago

I found the line that is causing the tableview to jump to the top when you use the pan gesture do dismiss the keyboard.

Down near the bottom of - (void)slk_handlePanGestureRecognizer:(UIPanGestureRecognizer *)gesture under the switch case case UIGestureRecognizerStateChanged: there is this block:

                if (self.isInverted) {
                    if (!self.scrollViewProxy.isDecelerating && self.scrollViewProxy.isTracking) {
                        self.scrollViewProxy.contentOffset = _scrollViewOffsetBeforeDragging;
                    }
                }
                else {
                    CGFloat keyboardHeightDelta = _keyboardHeightBeforeDragging-self.keyboardHC.constant;
                    offset.y -= keyboardHeightDelta;

                    self.scrollViewProxy.contentOffset = offset;
                }

The line: self.scrollViewProxy.contentOffset = offset; seems to be the culprit as the offset (for me) is (0,0) which forces the tableview to jump to the top.

Commenting out that line fixes the problem.

dzenbot commented 8 years ago

Interesting. Good catch! Will test it out.

dzenbot commented 8 years ago

Hey @tylerjames I wasn't able to repro. Which version are you using, and can you repro on iOS 9 and 8 consistently? Would you mind sharing a screencast to show how better reproduce this issue? That could be helpful to diagnose this.

tylerjames commented 8 years ago

Hi @dzenbot,

I probably won't get a chance to look at this again until the new year. It's entirely possible, however, that there are some other libraries and/or views that are causing conflicts with the SlackTextViewController. I find setting the tableViewHeader property and adding a UIRefreshControl can cause some strange behaviour in tables.

If I get a chance I'll try to reproduce with more info.

dzenbot commented 8 years ago

Closing this for now.