Skip to content

Commit 43d3c08

Browse files
authored
Use the only working iOS focus API (#166)
Seems like `UITextView.focused` and `UITextView.isFocused` stopped working overnight so I switched to the only focus check API that works now. Fixes issue with strange entering for new lists/quotes points.
1 parent 7832212 commit 43d3c08

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

ios/utils/TextInsertionUtils.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ + (void)insertText:(NSString*)text at:(NSInteger)index additionalAttributes:(NSD
1818
[textView.textStorage insertAttributedString:newAttrStr atIndex:index];
1919

2020
if(withSelection) {
21-
if(!textView.focused) {
21+
if(![textView isFirstResponder]) {
2222
[textView reactFocus];
2323
}
2424
textView.selectedRange = NSMakeRange(index + text.length, 0);
@@ -38,7 +38,7 @@ + (void)replaceText:(NSString*)text at:(NSRange)range additionalAttributes:(NSDi
3838
}
3939

4040
if(withSelection) {
41-
if(!textView.focused) {
41+
if(![textView isFirstResponder]) {
4242
[textView reactFocus];
4343
}
4444
textView.selectedRange = NSMakeRange(range.location + text.length, 0);

ios/utils/ZeroWidthSpaceUtils.mm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ + (void)removeSpacesIfNeededinInput:(EnrichedTextInputView *)input {
6363
}
6464

6565
// fix the selection if needed
66-
if(input->textView.focused) {
67-
[input->textView reactFocus];
66+
if([input->textView isFirstResponder]) {
6867
input->textView.selectedRange = NSMakeRange(preRemoveSelection.location + postRemoveOffset, preRemoveSelection.length);
6968
}
7069
}
@@ -112,8 +111,7 @@ + (void)addSpacesIfNeededinInput:(EnrichedTextInputView *)input {
112111
}
113112

114113
// fix the selection if needed
115-
if(input->textView.focused) {
116-
[input->textView reactFocus];
114+
if([input->textView isFirstResponder]) {
117115
input->textView.selectedRange = NSMakeRange(preAddSelection.location + postAddOffset, preAddSelection.length);
118116
}
119117
}

0 commit comments

Comments
 (0)