Fabric: Fixes TextInput crash when textShadowOffset is set and textShadowRadius is nan (#48296)

Summary:
Fixes https://github.com/facebook/react-native/issues/48288

## Changelog:

[IOS] [FIXED] - Fabric: Fixes TextInput crash when textShadowOffset is set and textShadowRadius is nan

Pull Request resolved: https://github.com/facebook/react-native/pull/48296

Test Plan: Repro demo in https://github.com/facebook/react-native/issues/48288

Reviewed By: cipolleschi

Differential Revision: D67334179

Pulled By: NickGerleman

fbshipit-source-id: a9456a152d31bef1666669cbded28d99ec8a2028
This commit is contained in:
zhongwuzw
2024-12-17 06:53:47 -08:00
committed by Facebook GitHub Bot
parent 5370347f54
commit 5c789c3d3a
@@ -303,8 +303,12 @@ NSMutableDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttri
auto textShadowOffset = textAttributes.textShadowOffset.value();
NSShadow *shadow = [NSShadow new];
shadow.shadowOffset = CGSize{textShadowOffset.width, textShadowOffset.height};
shadow.shadowBlurRadius = textAttributes.textShadowRadius;
shadow.shadowColor = RCTUIColorFromSharedColor(textAttributes.textShadowColor);
if (!isnan(textAttributes.textShadowRadius)) {
shadow.shadowBlurRadius = textAttributes.textShadowRadius;
}
if (textAttributes.textShadowColor) {
shadow.shadowColor = RCTUIColorFromSharedColor(textAttributes.textShadowColor);
}
attributes[NSShadowAttributeName] = shadow;
}