fix(ios/fabric): stop overriding JS width in Yoga layout#1036
fix(ios/fabric): stop overriding JS width in Yoga layout#1036Scr3nt wants to merge 2 commits intoreact-native-datetimepicker:masterfrom
Conversation
The `adopt` method in `ComponentDescriptors.h` called `setSize()` with both width and height from `sizeThatFits:UILayoutFittingCompressedSize`. Because `UIDatePicker` has a native minimum width of 280pt, this forced a fixed width on the Yoga node, overriding any JS style such as `width: "100%"`. Only set the **height** from the native measurement and let the JS side control the width through regular Yoga styles. Adds `setMeasuredHeight()` to `RNDateTimePickerShadowNode` which sets only `yoga::Dimension::Height` on the Yoga node style, leaving the width dimension untouched. Fixes react-native-datetimepicker#1014
|
I made the fix and tested all modes. |
|
Thank you fix!! |
|
Hello and thanks for the PR,
|
Thanks for the review! About the screenshots: the first one shows the picker constrained to ~280pt (the native minimum width forced by setSize()), while the second one shows it properly filling the available width as expected from the JS layout. About the width question: Previously, ComponentDescriptors.h called setSize() which set both width and height on the Yoga node style, effectively hardcoding the native measurement (minimum ~280pt) and overriding any JS style like width: "100%" or flex: 1. Now, only the height is set from the native side (via the new setMeasuredHeight()). The width is handled by standard Yoga layout just like most other React Native components. This means: If the user sets width: "100%" or flex: 1, it works as expected. Making it opt-in (measure width by default, skip only when a custom width is set) would require inspecting the Yoga node's style to check if a width was explicitly set by the user, which adds complexity for no real benefit. The standard RN pattern is to let Yoga handle width from the JS side. |


Summary
The
adoptmethod inComponentDescriptors.hcallssetSize()with both width and height fromsizeThatFits:UILayoutFittingCompressedSize. BecauseUIDatePickerhas a native minimum width of 280pt, this forces a fixed width on the Yoga node, overriding any JS style such aswidth: "100%".This PR changes the native layout code to only set the height from the native measurement, letting the JS side control the width through regular Yoga styles.
Changes
ShadowNodes.h: AddsetMeasuredHeight(float)method that only setsyoga::Dimension::Heighton the Yoga node style, leaving the width untouchedComponentDescriptors.h: ReplacesetSize()call withsetMeasuredHeight()in theadoptmethodBefore / After
Fixes #1014