Skip to content

Commit e3cf545

Browse files
author
Ignacio Romero Zurbuchen
committed
Fixes SLKKeyboard notifications not being fired accordantly
Fixes slackhq#290
1 parent 7df6239 commit e3cf545

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Source/SLKTextViewController.m

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,14 +1328,13 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13281328
}
13291329
}
13301330

1331-
NSInteger curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
1332-
NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
1333-
1334-
CGRect beginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
1335-
CGRect endFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
1336-
13371331
SLKKeyboardStatus status = [self slk_keyboardStatusForNotification:notification];
13381332

1333+
// Skips if it's the current status
1334+
if (self.keyboardStatus == status) {
1335+
return;
1336+
}
1337+
13391338
// Programatically stops scrolling before updating the view constraints (to avoid scrolling glitch).
13401339
if (status == SLKKeyboardStatusWillShow) {
13411340
[self.scrollViewProxy slk_stopScrolling];
@@ -1356,6 +1355,12 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
13561355
[self slk_postKeyboarStatusNotification:notification];
13571356
}
13581357

1358+
NSInteger curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
1359+
NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
1360+
1361+
CGRect beginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
1362+
CGRect endFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
1363+
13591364
void (^animations)() = ^void() {
13601365
[self slk_scrollToBottomIfNeeded];
13611366
};
@@ -1395,7 +1400,8 @@ - (void)slk_didShowOrHideKeyboard:(NSNotification *)notification
13951400

13961401
SLKKeyboardStatus status = [self slk_keyboardStatusForNotification:notification];
13971402

1398-
if (status == SLKKeyboardStatusDidHide) {
1403+
// Skips if it's the current status
1404+
if (self.keyboardStatus == status) {
13991405
return;
14001406
}
14011407

0 commit comments

Comments
 (0)