Skip to content

Commit 53cc3bd

Browse files
committed
Ignore ReactForegroundColorSpan when stroke is present
1 parent d6a479e commit 53cc3bd

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ private static void buildSpannedFromShadowNode(
173173
}
174174
int end = sb.length();
175175
if (end >= start) {
176-
if (textShadowNode.mIsColorSet) {
176+
// Skip ReactForegroundColorSpan when stroke is present - StrokeStyleSpan handles both stroke and fill colors
177+
boolean hasStroke = !Float.isNaN(textShadowNode.mTextStrokeWidth)
178+
&& textShadowNode.mTextStrokeWidth > 0
179+
&& textShadowNode.mIsTextStrokeColorSet;
180+
if (textShadowNode.mIsColorSet && !hasStroke) {
177181
ops.add(new SetSpanOperation(start, end, new ReactForegroundColorSpan(textShadowNode.mColor)));
178182
}
179183
if (textShadowNode.mGradientColors != null && textShadowNode.mGradientColors.length >= 2) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ internal object TextLayoutManager {
254254
if (roleIsLink) {
255255
ops.add(SetSpanOperation(start, end, ReactClickableSpan(reactTag)))
256256
}
257-
if (textAttributes.mIsColorSet) {
257+
// Skip ReactForegroundColorSpan when stroke is present - StrokeStyleSpan handles both stroke and fill colors
258+
val hasStroke = !textAttributes.textStrokeWidth.isNaN() &&
259+
textAttributes.textStrokeWidth > 0 &&
260+
textAttributes.isTextStrokeColorSet
261+
if (textAttributes.mIsColorSet && !hasStroke) {
258262
ops.add(SetSpanOperation(start, end, ReactForegroundColorSpan(textAttributes.mColor)))
259263
}
260264
if (textAttributes.gradientColors != null && textAttributes.gradientColors!!.size >= 2) {
@@ -412,7 +416,11 @@ internal object TextLayoutManager {
412416
spannable.setSpan(ReactClickableSpan(fragment.reactTag), start, end, spanFlags)
413417
}
414418

415-
if (fragment.props.isColorSet) {
419+
// Skip ReactForegroundColorSpan when stroke is present - StrokeStyleSpan handles both stroke and fill colors
420+
val hasStroke = !fragment.props.textStrokeWidth.isNaN() &&
421+
fragment.props.textStrokeWidth > 0 &&
422+
fragment.props.isTextStrokeColorSet
423+
if (fragment.props.isColorSet && !hasStroke) {
416424
spannable.setSpan(ReactForegroundColorSpan(fragment.props.color), start, end, spanFlags)
417425
}
418426

0 commit comments

Comments
 (0)