Skip to content

Commit d9bb79d

Browse files
christophpurrerShawn Dempsey
authored andcommitted
Fix TextInput interfering with Japanese conversion (microsoft#1358)
1 parent 8e364fb commit d9bb79d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ NS_ASSUME_NONNULL_BEGIN
7676
#endif // ]TODO(macOS GH#774)
7777

7878
#if TARGET_OS_OSX // [TODO(macOS GH#774)
79+
- (BOOL)hasMarkedText;
7980
// UITextInput method for OSX
8081
- (CGSize)sizeThatFits:(CGSize)size;
8182
#endif // ]TODO(macOS GH#774)

Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ - (void)setAttributedText:(NSAttributedString *)attributedText
155155
range:NSMakeRange(0, attributedTextCopy.length)];
156156

157157
textNeedsUpdate = ([self textOf:attributedTextCopy equals:backedTextInputViewTextCopy] == NO);
158+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
159+
// If we are in a language that uses conversion (e.g. Japanese), ignore updates if we have unconverted text.
160+
if ([self.backedTextInputView hasMarkedText]) {
161+
textNeedsUpdate = NO;
162+
}
163+
#endif // ]TODO(macOS GH#774)
158164

159165
if (eventLag == 0 && textNeedsUpdate) {
160166
#if !TARGET_OS_OSX // TODO(macOS GH#774)

Libraries/Text/TextInput/Singleline/RCTUITextField.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ - (void)_textDidChange
125125
#endif // ]TODO(macOS GH#774)
126126
}
127127

128+
#if TARGET_OS_OSX // [TODO(macOS GH#774)
129+
- (BOOL)hasMarkedText
130+
{
131+
return ((NSTextView *)self.currentEditor).hasMarkedText;
132+
}
133+
#endif // ]TODO(macOS GH#774)
134+
128135
#pragma mark - Accessibility
129136

130137
#if !TARGET_OS_OSX // [TODO(macOS GH#774)

0 commit comments

Comments
 (0)