Skip to content

Commit 2bece45

Browse files
committed
fix(ios/fabric): stop overriding JS width in Yoga layout
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 #1014
1 parent 2a26378 commit 2bece45

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ios/fabric/cpp/react/renderer/components/RNDateTimePicker/ComponentDescriptors.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ class RNDateTimePickerComponentDescriptor final : public ConcreteComponentDescri
2020

2121
void adopt(ShadowNode& shadowNode) const override {
2222
auto& pickerShadowNode = static_cast<RNDateTimePickerShadowNode&>(shadowNode);
23-
auto& layoutableShadowNode = static_cast<YogaLayoutableShadowNode&>(pickerShadowNode);
2423

2524
auto state = std::static_pointer_cast<const RNDateTimePickerShadowNode::ConcreteState>(shadowNode.getState());
2625
auto stateData = state->getData();
2726

28-
if(stateData.frameSize.width != 0 && stateData.frameSize.height != 0) {
29-
layoutableShadowNode.setSize(Size{stateData.frameSize.width, stateData.frameSize.height});
27+
if(stateData.frameSize.height != 0) {
28+
pickerShadowNode.setMeasuredHeight(stateData.frameSize.height);
3029
}
3130

3231
ConcreteComponentDescriptor::adopt(shadowNode);

ios/fabric/cpp/react/renderer/components/RNDateTimePicker/ShadowNodes.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class JSI_EXPORT RNDateTimePickerShadowNode final : public ConcreteViewShadowNod
3333
traits.set(ShadowNodeTraits::Trait::LeafYogaNode);
3434
return traits;
3535
}
36+
37+
void setMeasuredHeight(float height) const {
38+
auto style = yogaNode_.style();
39+
style.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(height));
40+
yogaNode_.setStyle(style);
41+
yogaNode_.setDirty(true);
42+
}
3643
};
3744

3845
} // namespace react

0 commit comments

Comments
 (0)