Skip to content

Commit 2b0b3ff

Browse files
author
ignacio
committed
Fixes an issue when text was cached while auto-completing, it would present the auto-completion view before the view is visible, disabling scroll gesture and causing other side effects.
1 parent a98cb94 commit 2b0b3ff

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Source/Additions/UIResponder+SLKAdditions.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ + (instancetype)slk_currentFirstResponder
2727
{
2828
___currentFirstResponder = nil;
2929
[[UIApplication sharedApplication] sendAction:@selector(slk_findFirstResponder:) to:nil from:nil forEvent:nil];
30+
3031
return ___currentFirstResponder;
3132
}
3233

Source/Classes/SLKTextViewController.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ @interface SLKTextViewController ()
5959
@property (nonatomic) BOOL newWordInserted;
6060

6161
// YES if the view controller did appear and everything is finished configurating. This allows blocking some layout animations among other things.
62-
@property (nonatomic) BOOL isViewVisible;
62+
@property (nonatomic, getter=isViewVisible) BOOL viewVisible;
6363

6464
// The setter of isExternalKeyboardDetected, for private use.
6565
@property (nonatomic, getter = isRotating) BOOL rotating;
@@ -201,7 +201,7 @@ - (void)viewDidAppear:(BOOL)animated
201201

202202
[self.scrollViewProxy flashScrollIndicators];
203203

204-
self.isViewVisible = YES;
204+
self.viewVisible = YES;
205205
}
206206

207207
- (void)viewWillDisappear:(BOOL)animated
@@ -211,7 +211,7 @@ - (void)viewWillDisappear:(BOOL)animated
211211
// Stops the keyboard from being dismissed during the navigation controller's "swipe-to-pop"
212212
self.textView.didNotResignFirstResponder = self.isMovingFromParentViewController;
213213

214-
self.isViewVisible = NO;
214+
self.viewVisible = NO;
215215

216216
// Caches the text before it's too late!
217217
[self slk_cacheTextView];
@@ -1297,8 +1297,10 @@ - (void)slk_didChangeTextViewText:(NSNotification *)notification
12971297
// Animated only if the view already appeared.
12981298
[self textDidUpdate:self.isViewVisible];
12991299

1300-
// Process the text at text change
1301-
[self slk_processTextForAutoCompletion];
1300+
// Process the text at every change, when the view is visible
1301+
if (self.isViewVisible) {
1302+
[self slk_processTextForAutoCompletion];
1303+
}
13021304
}
13031305

13041306
- (void)slk_didChangeTextViewContentSize:(NSNotification *)notification
@@ -1720,7 +1722,7 @@ - (void)textViewDidChange:(UITextView *)textView
17201722
// Keep to avoid unnecessary crashes. Was meant to be overriden in subclass while calling super.
17211723
}
17221724

1723-
- (void)textViewDidChangeSelection:(SLKTextView *)textView
1725+
- (void)textViewDidChangeSelection:(UITextView *)textView
17241726
{
17251727
// Keep to avoid unnecessary crashes. Was meant to be overriden in subclass while calling super.
17261728
}

0 commit comments

Comments
 (0)