Skip to content

Commit ea91884

Browse files
shubh73claude
andcommitted
Fix shadowColor and outline prop defaults in BaseViewManagerDelegate
BaseViewManagerDelegate reset shadowColor to 0 and outlineOffset and outlineWidth to YogaConstants.UNDEFINED when the props were removed, instead of the @ReactProp defaults in BaseViewManager (Color.BLACK and 0f). On components with a codegen delegate, removing shadowColor hid the elevation shadow and removing outlineOffset hid the outline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1ca5679 commit ea91884

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.kt‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package com.facebook.react.uimanager
99

10+
import android.graphics.Color
1011
import android.view.View
1112
import com.facebook.react.bridge.ColorPropConverter
1213
import com.facebook.react.bridge.Dynamic
@@ -89,7 +90,10 @@ public abstract class BaseViewManagerDelegate<
8990
ViewProps.MIX_BLEND_MODE -> mViewManager.setMixBlendMode(view, value as String?)
9091

9192
ViewProps.SHADOW_COLOR ->
92-
mViewManager.setShadowColor(view, ColorPropConverter.getColor(value, view.context, 0))
93+
mViewManager.setShadowColor(
94+
view,
95+
ColorPropConverter.getColor(value, view.context, Color.BLACK),
96+
)
9397

9498
ViewProps.IMPORTANT_FOR_ACCESSIBILITY ->
9599
mViewManager.setImportantForAccessibility(view, value as String?)
@@ -113,18 +117,12 @@ public abstract class BaseViewManagerDelegate<
113117
)
114118

115119
ViewProps.OUTLINE_OFFSET ->
116-
mViewManager.setOutlineOffset(
117-
view,
118-
(value as Double?)?.toFloat() ?: YogaConstants.UNDEFINED,
119-
)
120+
mViewManager.setOutlineOffset(view, (value as Double?)?.toFloat() ?: 0.0f)
120121

121122
ViewProps.OUTLINE_STYLE -> mViewManager.setOutlineStyle(view, value as String?)
122123

123124
ViewProps.OUTLINE_WIDTH ->
124-
mViewManager.setOutlineWidth(
125-
view,
126-
(value as Double?)?.toFloat() ?: YogaConstants.UNDEFINED,
127-
)
125+
mViewManager.setOutlineWidth(view, (value as Double?)?.toFloat() ?: 0.0f)
128126

129127
ViewProps.RENDER_TO_HARDWARE_TEXTURE ->
130128
mViewManager.setRenderToHardwareTexture(view, value as Boolean? ?: false)

‎packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/BaseViewManagerDelegateTest.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static org.mockito.Mockito.mock;
1111
import static org.mockito.Mockito.verify;
1212

13+
import android.graphics.Color;
1314
import com.facebook.react.bridge.ReactApplicationContext;
1415
import com.facebook.react.bridge.ReactTestHelper;
1516
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
@@ -60,4 +61,25 @@ public void setOutlineColorPreservesNull() {
6061

6162
verify(viewManager).setOutlineColor(view, null);
6263
}
64+
65+
@Test
66+
public void setShadowColorResetsToBlack() {
67+
delegate.setProperty(view, ViewProps.SHADOW_COLOR, null);
68+
69+
verify(viewManager).setShadowColor(view, Color.BLACK);
70+
}
71+
72+
@Test
73+
public void setOutlineOffsetResetsToZero() {
74+
delegate.setProperty(view, ViewProps.OUTLINE_OFFSET, null);
75+
76+
verify(viewManager).setOutlineOffset(view, 0f);
77+
}
78+
79+
@Test
80+
public void setOutlineWidthResetsToZero() {
81+
delegate.setProperty(view, ViewProps.OUTLINE_WIDTH, null);
82+
83+
verify(viewManager).setOutlineWidth(view, 0f);
84+
}
6385
}

0 commit comments

Comments
 (0)