Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,30 @@ - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTe
return [newText.string isEqualToString:oldText.string];
} else {
return RCTIsAttributedStringEffectivelySame(
newText, oldText, _originalTypingAttributes, static_cast<const TextInputProps &>(*_props).textAttributes);
}
newText,
oldText,
[self _insensitiveTypingAttributes],
static_cast<const TextInputProps &>(*_props).textAttributes);
}
}

// UIKit injects typing attributes lazily — e.g. NSBackgroundColor while marked text is
// in flight during autocorrect/IME composition. The set captured at init only contains
// pre-focus attributes (NSColor, NSParagraphStyle, NSFont), so attributes added after
// focus would be treated as JS-imposed differences and trigger a destructive
// `setAttributedText:` mid-composition (the controlled-input "jumbled text" bug). Union
// the init snapshot with the live typing attributes so the comparison stays insensitive
// to anything UIKit silently adds.
- (NSDictionary<NSAttributedStringKey, id> *)_insensitiveTypingAttributes
{
NSDictionary<NSAttributedStringKey, id> *liveTypingAttributes = _backedTextInputView.typingAttributes;
if (liveTypingAttributes.count == 0) {
return _originalTypingAttributes;
}
NSMutableDictionary<NSAttributedStringKey, id> *merged =
[NSMutableDictionary dictionaryWithDictionary:_originalTypingAttributes];
[merged addEntriesFromDictionary:liveTypingAttributes];
return merged;
}

- (SubmitBehavior)getSubmitBehavior
Expand Down
Loading