diff --git a/packages/react-native/Libraries/Text/RCTTextAttributes.mm b/packages/react-native/Libraries/Text/RCTTextAttributes.mm index e3f9a0af583e..2ee06afd37bb 100644 --- a/packages/react-native/Libraries/Text/RCTTextAttributes.mm +++ b/packages/react-native/Libraries/Text/RCTTextAttributes.mm @@ -277,7 +277,7 @@ - (CGFloat)effectiveFontSizeMultiplier - (RCTPlatformColor *)effectiveForegroundColor // [macOS] { - RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTPlatformColor blackColor]; // [macOS] + RCTPlatformColor *effectiveForegroundColor = _foregroundColor ?: [RCTTextAttributes defaultForegroundColor]; // [macOS] if (!isnan(_opacity)) { effectiveForegroundColor = diff --git a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm index 8c71181b26a8..c5ae3fe6ed07 100644 --- a/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm +++ b/packages/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.mm @@ -69,7 +69,7 @@ - (instancetype)initWithFrame:(CGRect)frame _textInputDelegateAdapter = [[RCTBackedTextViewDelegateAdapter alloc] initWithTextView:self]; self.backgroundColor = [RCTPlatformColor clearColor]; // [macOS] - self.textColor = [RCTPlatformColor blackColor]; // [macOS] + self.textColor = [RCTPlatformColor labelColor]; // [macOS] // This line actually removes 5pt (default value) left and right padding in UITextView. #if !TARGET_OS_OSX // [macOS] self.textContainer.lineFragmentPadding = 0; diff --git a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm index 572bf21ef4a3..188ddf034750 100644 --- a/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm +++ b/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm @@ -127,7 +127,7 @@ - (void)enforceTextAttributesIfNeeded NSDictionary *textAttributes = [[_textAttributes effectiveTextAttributes] mutableCopy]; if ([textAttributes valueForKey:NSForegroundColorAttributeName] == nil) { - [textAttributes setValue:[RCTPlatformColor blackColor] forKey:NSForegroundColorAttributeName]; // [macOS] + [textAttributes setValue:[RCTPlatformColor labelColor] forKey:NSForegroundColorAttributeName]; // [macOS] } backedTextInputView.defaultTextAttributes = textAttributes; diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp b/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp index 2982e5923693..f042d94777e6 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp @@ -178,7 +178,7 @@ TextAttributes TextAttributes::defaultTextAttributes() { static auto textAttributes = [] { auto textAttributes = TextAttributes{}; // Non-obvious (can be different among platforms) default text attributes. - textAttributes.foregroundColor = blackColor(); + textAttributes.foregroundColor = defaultForegroundTextColor(); // [macOS] textAttributes.backgroundColor = clearColor(); textAttributes.fontSize = 14.0; textAttributes.fontSizeMultiplier = 1.0; diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/Color.h b/packages/react-native/ReactCommon/react/renderer/graphics/Color.h index 5c2dd9aa509b..6fed98d9d9e7 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/Color.h +++ b/packages/react-native/ReactCommon/react/renderer/graphics/Color.h @@ -70,6 +70,7 @@ SharedColor colorFromRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a); SharedColor clearColor(); SharedColor blackColor(); SharedColor whiteColor(); +SharedColor defaultForegroundTextColor(); // [macOS] #ifdef RN_SERIALIZABLE_STATE inline folly::dynamic toDynamic(const SharedColor& sharedColor) { diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm index ed55f28aa664..15395d0b70fe 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +++ b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm @@ -10,6 +10,7 @@ #import #import // [macOS] #import +#import // [macOS] #import #import #import @@ -342,6 +343,16 @@ int32_t ColorFromUIColor(const std::shared_ptr &uiColor) return Color(wrapManagedObject(semanticColor)); } +// [macOS +SharedColor defaultForegroundTextColor() { + static SharedColor color = [] { + std::vector items = {"labelColor"}; + return SharedColor(Color::createSemanticColor(items)); + }(); + return color; +} +// macOS] + } // namespace facebook::react NS_ASSUME_NONNULL_END 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 5ff1c376da8b..207a5f044e0e 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 @@ -144,7 +144,7 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex inline static RCTPlatformColor *RCTEffectiveForegroundColorFromTextAttributes(const TextAttributes &textAttributes) // [macOS] { - RCTPlatformColor *effectiveForegroundColor = RCTUIColorFromSharedColor(textAttributes.foregroundColor) ? RCTUIColorFromSharedColor(textAttributes.foregroundColor) : [RCTPlatformColor blackColor]; // [macOS] + RCTPlatformColor *effectiveForegroundColor = RCTUIColorFromSharedColor(textAttributes.foregroundColor) ?: [RCTPlatformColor labelColor]; // [macOS] if (!isnan(textAttributes.opacity)) { effectiveForegroundColor = [effectiveForegroundColor