Skip to content

Commit 0c3f2fb

Browse files
authored
Do not create m_childrenContainer when using a custom visual to mount children into (#15877)
* Do not create m_childrenContainer when using a custom visual to mount children into * Change files * fix
1 parent 855a194 commit 0c3f2fb

6 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Do not create m_childrenContainer when using a custom visual to mount children into",
4+
"packageName": "react-native-windows",
5+
"email": "30809111+acoates-ms@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/AbiViewProps.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,11 @@ winrt::hstring ViewProps::AccessibilityLabel() noexcept {
226226
return m_viewProps ? winrt::to_hstring(m_viewProps->accessibilityLabel) : winrt::hstring{};
227227
}
228228

229+
winrt::Microsoft::ReactNative::Overflow ViewProps::Overflow() noexcept {
230+
return m_viewProps ? static_cast<winrt::Microsoft::ReactNative::Overflow>(m_viewProps->yogaStyle.overflow())
231+
: winrt::Microsoft::ReactNative::Overflow::Visible;
232+
}
233+
229234
ImageProps::ImageProps(facebook::react::SharedViewProps props) noexcept : Super(props) {}
230235

231236
winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::ReactNative::ImageSource>

vnext/Microsoft.ReactNative/Fabric/AbiViewProps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ struct ViewProps : ViewPropsT<ViewProps> {
9999
winrt::Microsoft::ReactNative::Color BackgroundColor() noexcept;
100100
winrt::hstring TestId() noexcept;
101101
winrt::hstring AccessibilityLabel() noexcept;
102+
winrt::Microsoft::ReactNative::Overflow Overflow() noexcept;
102103

103104
protected:
104105
facebook::react::SharedViewProps m_props;

vnext/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,10 @@ void ViewComponentView::updateLayoutMetrics(
13481348
void ViewComponentView::updateChildrenClippingPath(
13491349
facebook::react::LayoutMetrics const &layoutMetrics,
13501350
const facebook::react::ViewProps &viewProps) noexcept {
1351+
// Views with a custom visual to mount children into should to do their own handling of children clipping path
1352+
if (m_builder && m_builder->VisualToMountChildrenIntoHandler())
1353+
return;
1354+
13511355
const float scale = layoutMetrics.pointScaleFactor;
13521356
const float viewWidth = layoutMetrics.frame.size.width * scale;
13531357
const float viewHeight = layoutMetrics.frame.size.height * scale;

vnext/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ namespace Microsoft.ReactNative.Composition
7373
void SetCreateVisualHandler(CreateVisualDelegate impl);
7474
void SetViewFeatures(ComponentViewFeatures viewFeatures);
7575
void SetUpdateLayoutMetricsHandler(UpdateLayoutMetricsDelegate impl);
76+
77+
DOC_STRING("Provides a customized ContainerVisual that this components children will be mounted into. When overriding this, a clip is no longer automatically applied for overflow:\"hidden\"")
7678
void SetVisualToMountChildrenIntoHandler(VisualToMountChildrenIntoDelegate impl);
7779
};
7880

vnext/Microsoft.ReactNative/ViewProps.idl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ namespace Microsoft.ReactNative {
3030
static void WriteValue(IJSValueWriter writer, Color color);
3131
};
3232

33+
[experimental]
34+
enum Overflow
35+
{
36+
Visible,
37+
Hidden,
38+
Scroll,
39+
};
40+
3341
[webhosthidden]
3442
[experimental]
3543
DOC_STRING("Interface to implement custom view component properties.")
@@ -51,6 +59,7 @@ namespace Microsoft.ReactNative {
5159
Color BackgroundColor { get; };
5260
String TestId { get; };
5361
String AccessibilityLabel { get; };
62+
Overflow Overflow { get; };
5463

5564
// TODO add accessors to all the properties on ViewProps
5665
};

0 commit comments

Comments
 (0)