From 4ccc69419454e66c5c2f54882d048c71959fe805 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 20 Jun 2024 02:23:51 -0700 Subject: [PATCH] Handle textAlignment: start and make logs consistent (#45076) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45076 > **start**: The same as left if direction is left-to-right and right if direction is right-to-left. This is equivalent to `auto`, which is not actually a valid CSS value. Changelog: [General][Added] Add support for `texAlignment: 'start'` Differential Revision: D58791937 --- .../renderer/attributedstring/conversions.h | 3 +-- .../renderer/components/view/conversions.h | 20 +++++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h index a975fe080d9b33..d2a40f49765304 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h @@ -413,7 +413,7 @@ inline void fromRawValue( react_native_expect(value.hasType()); if (value.hasType()) { auto string = (std::string)value; - if (string == "auto") { + if (string == "auto" || string == "start") { result = TextAlignment::Natural; } else if (string == "left") { result = TextAlignment::Left; @@ -425,7 +425,6 @@ inline void fromRawValue( result = TextAlignment::Justified; } else { LOG(ERROR) << "Unsupported TextAlignment value: " << string; - react_native_expect(false); // sane default for prod result = TextAlignment::Natural; } diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h index e11e075b52a789..d1cd9b9ac0fc85 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/view/conversions.h @@ -188,8 +188,7 @@ inline void fromRawValue( result = yoga::Direction::RTL; return; } - LOG(ERROR) << "Could not parse Direction:" << stringValue; - react_native_expect(false); + LOG(ERROR) << "Could not parse yoga::Direction: " << stringValue; } inline void fromRawValue( @@ -218,8 +217,7 @@ inline void fromRawValue( result = yoga::FlexDirection::RowReverse; return; } - LOG(ERROR) << "Could not parse yoga::FlexDirection:" << stringValue; - react_native_expect(false); + LOG(ERROR) << "Could not parse yoga::FlexDirection: " << stringValue; } inline void fromRawValue( @@ -256,8 +254,7 @@ inline void fromRawValue( result = yoga::Justify::SpaceEvenly; return; } - LOG(ERROR) << "Could not parse yoga::Justify:" << stringValue; - react_native_expect(false); + LOG(ERROR) << "Could not parse yoga::Justify: " << stringValue; } inline void fromRawValue( @@ -306,7 +303,7 @@ inline void fromRawValue( result = yoga::Align::SpaceEvenly; return; } - LOG(ERROR) << "Could not parse yoga::Align:" << stringValue; + LOG(ERROR) << "Could not parse yoga::Align: " << stringValue; react_native_expect(false); } @@ -332,8 +329,7 @@ inline void fromRawValue( result = yoga::PositionType::Absolute; return; } - LOG(ERROR) << "Could not parse yoga::PositionType:" << stringValue; - react_native_expect(false); + LOG(ERROR) << "Could not parse yoga::PositionType: " << stringValue; } inline void fromRawValue( @@ -358,8 +354,7 @@ inline void fromRawValue( result = yoga::Wrap::WrapReverse; return; } - LOG(ERROR) << "Could not parse yoga::Wrap:" << stringValue; - react_native_expect(false); + LOG(ERROR) << "Could not parse yoga::Wrap: " << stringValue; } inline void fromRawValue( @@ -406,8 +401,7 @@ inline void fromRawValue( result = yoga::Display::None; return; } - LOG(ERROR) << "Could not parse yoga::Display:" << stringValue; - react_native_expect(false); + LOG(ERROR) << "Could not parse yoga::Display: " << stringValue; } inline void fromRawValue(