diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 8c532d85502bc1..0822b637bfcbd0 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -756,4 +756,4 @@ - (SubmitBehavior)getSubmitBehavior Class RCTTextInputCls(void) { return RCTTextInputComponentView.class; -} +} \ No newline at end of file diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm index 2b2cf02fa11604..bac33aee702169 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm @@ -178,6 +178,22 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex return effectiveBackgroundColor ?: [UIColor clearColor]; } +NSDictionary *RCTDefaultTextAttributes() { + static NSDictionary *defaultAttributes; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + defaultAttributes = @{ + NSFontAttributeName : [UIFont systemFontOfSize:14.0f], + NSForegroundColorAttributeName : [UIColor blackColor], + NSBackgroundColorAttributeName : [UIColor clearColor], + NSParagraphStyleAttributeName  : [NSParagraphStyle defaultParagraphStyle], + NSShadowAttributeName : [NSShadow new], + // Add other missing attributes as needed + }; + }); + return defaultAttributes; +} + NSDictionary *RCTNSTextAttributesFromTextAttributes(const TextAttributes &textAttributes) { NSMutableDictionary *attributes = [NSMutableDictionary dictionaryWithCapacity:10]; @@ -302,6 +318,14 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex attributes[RCTTextAttributesAccessibilityRoleAttributeName] = [NSString stringWithUTF8String:roleStr.c_str()]; } + // Apply default attributes if they're missing + NSDictionary *defaultAttributes = RCTDefaultTextAttributes(); + for (NSAttributedStringKey key in defaultAttributes) { + if (![attributes objectForKey:key]) { + attributes[key] = defaultAttributes[key]; + } + } + return [attributes copy]; }