Skip to content

Commit

Permalink
fix(ios): drag-and-drop text in TextArea can crash on iOS 15
Browse files Browse the repository at this point in the history
Fixes TIMOB-28556
  • Loading branch information
jquick-axway authored and ewanharris committed Nov 17, 2021
1 parent 248763a commit 5ebb9d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions iphone/Classes/TiUITextArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@property (nonatomic, readwrite, assign) BOOL enableCopy;

- (void)setTouchHandler:(TiUIView *)handler;
- (NSComparisonResult)comparePosition:(UITextPosition *)position toPosition:(UITextPosition *)other;

@end

Expand Down
14 changes: 13 additions & 1 deletion iphone/Classes/TiUITextArea.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ - (void)setTouchHandler:(TiUIView *)handler
touchHandler = handler;
}

- (NSComparisonResult)comparePosition:(UITextPosition *)position toPosition:(UITextPosition *)other
{
NSComparisonResult result = NSOrderedAscending;
@try {
result = [super comparePosition:position toPosition:other];
}
@catch (NSException *ex) {
// Ignore exception that can occur on iOS 15 if "maxLength" trims text that was dragged-and-dropped.
}
return result;
}

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
{
//If the content view is of type TiUIView touch events will automatically propagate
Expand Down Expand Up @@ -376,7 +388,7 @@ - (BOOL)textView:(UITextView *)tv shouldChangeTextInRange:(NSRange)range replace
}
}

return TRUE;
return YES;
}

- (void)setHandleLinks_:(id)args
Expand Down

0 comments on commit 5ebb9d2

Please sign in to comment.