Skip to content

Commit 6cfe51d

Browse files
shwantonfacebook-github-bot
authored andcommitted
Border Radius percentage should be disabled on Paper (facebook#46179)
Summary: Pull Request resolved: facebook#46179 Changelog: [Internal] **Context** - When debugging E2E tests, we found RNTester Legacy Arch builds were rendering border radius w/ percentages in a strange way - The issues was only noticeable on production e2e builds - Support for percentage on borderRadius ViewStyle props was added in D56198302 - This should be fabric only, but the same props are parsed on Paper **Change** - Add Custom Conversion for BorderRadius on Paper - Only Parse integer border radius values Reviewed By: philIip Differential Revision: D61686841 fbshipit-source-id: cc24d3dbdb82b1dcb90f18fc44d5d13d3e6465b4
1 parent 09e8844 commit 6cfe51d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

packages/react-native/React/Views/RCTViewManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,7 @@ typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, NSDictionary<NSNu
115115
RCT_REMAP_SHADOW_PROPERTY(name, __custom__, type) \
116116
-(void)set_##name : (id)json forShadowView : (viewClass *)view RCT_DYNAMIC
117117

118+
// Parse a JSON object and only return the number value, eveything else returns a 0
119+
CGFloat RCTJSONParseOnlyNumber(id json);
120+
118121
@end

packages/react-native/React/Views/RCTViewManager.m

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,9 @@ - (void)updateAccessibilityTraitsForRole:(RCTView *)view withDefaultView:(RCTVie
370370
RCT_CUSTOM_VIEW_PROPERTY(borderRadius, CGFloat, RCTView)
371371
{
372372
if ([view respondsToSelector:@selector(setBorderRadius:)]) {
373-
view.borderRadius = json ? [RCTConvert CGFloat:json] : defaultView.borderRadius;
373+
view.borderRadius = json ? RCTJSONParseOnlyNumber(json) : defaultView.borderRadius;
374374
} else {
375-
view.layer.cornerRadius = json ? [RCTConvert CGFloat:json] : defaultView.layer.cornerRadius;
375+
view.layer.cornerRadius = json ? RCTJSONParseOnlyNumber(json) : defaultView.layer.cornerRadius;
376376
}
377377
}
378378
RCT_CUSTOM_VIEW_PROPERTY(borderColor, UIColor, RCTView)
@@ -476,12 +476,12 @@ - (void)updateAccessibilityTraitsForRole:(RCTView *)view withDefaultView:(RCTVie
476476
RCT_VIEW_BORDER_PROPERTY(BlockEnd)
477477
RCT_VIEW_BORDER_PROPERTY(BlockStart)
478478

479-
#define RCT_VIEW_BORDER_RADIUS_PROPERTY(SIDE) \
480-
RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Radius, CGFloat, RCTView) \
481-
{ \
482-
if ([view respondsToSelector:@selector(setBorder##SIDE##Radius:)]) { \
483-
view.border##SIDE##Radius = json ? [RCTConvert CGFloat:json] : defaultView.border##SIDE##Radius; \
484-
} \
479+
#define RCT_VIEW_BORDER_RADIUS_PROPERTY(SIDE) \
480+
RCT_CUSTOM_VIEW_PROPERTY(border##SIDE##Radius, CGFloat, RCTView) \
481+
{ \
482+
if ([view respondsToSelector:@selector(setBorder##SIDE##Radius:)]) { \
483+
view.border##SIDE##Radius = json ? RCTJSONParseOnlyNumber(json) : defaultView.border##SIDE##Radius; \
484+
} \
485485
}
486486

487487
RCT_VIEW_BORDER_RADIUS_PROPERTY(TopLeft)
@@ -739,4 +739,12 @@ - (void)updateAccessibilityTraitsForRole:(RCTView *)view withDefaultView:(RCTVie
739739
RCT_EXPORT_VIEW_PROPERTY(onGotPointerCapture, RCTBubblingEventBlock)
740740
RCT_EXPORT_VIEW_PROPERTY(onLostPointerCapture, RCTBubblingEventBlock)
741741

742+
CGFloat RCTJSONParseOnlyNumber(id json)
743+
{
744+
if ([json isKindOfClass:[NSNumber class]]) {
745+
return [RCTConvert CGFloat:json];
746+
}
747+
return 0.0f;
748+
}
749+
742750
@end

0 commit comments

Comments
 (0)