diff --git a/doc/ReleaseNotes/_ReleaseNotes.md b/doc/ReleaseNotes/_ReleaseNotes.md
index d7168fa8e0b3..10bc47f55fb4 100644
--- a/doc/ReleaseNotes/_ReleaseNotes.md
+++ b/doc/ReleaseNotes/_ReleaseNotes.md
@@ -95,6 +95,7 @@
- #2570 [Android/iOS] fixed ObjectDisposedException in BindingPath
- #2107 [iOS] fixed ContentDialog doesn't block touch for background elements
- #2108 [iOS/Android] fixed ContentDialog background doesn't change
+- #2680 [Wasm] Fix ComboBox should not stretch to the full window width
## Release 2.0
diff --git a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ComboBoxTests/UnoSamples_Tests.ComboBoxTests.cs b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ComboBoxTests/UnoSamples_Tests.ComboBoxTests.cs
index 1b6b45146d19..c6a1202d86cc 100644
--- a/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ComboBoxTests/UnoSamples_Tests.ComboBoxTests.cs
+++ b/src/SamplesApp/SamplesApp.UITests/Windows_UI_Xaml_Controls/ComboBoxTests/UnoSamples_Tests.ComboBoxTests.cs
@@ -98,5 +98,26 @@ public void ComboBoxTests_VisibleBounds()
// compensates for a possible change of origins with android popups.
Assert.AreEqual(popupLocationDifference - sampleControlResultExtended.Rect.Y, popupLocationDifferenceExtended);
}
+
+
+ [Test]
+ [AutoRetry]
+ public void ComboBoxTests_Stretch()
+ {
+ Run("UITests.Windows_UI_Xaml_Controls.ComboBox.ComboBox_Stretch");
+
+ var combo01 = _app.Marked("combo01");
+ var sampleControl = _app.Marked("sampleControl");
+ var changeExtended = _app.Marked("changeExtended");
+
+ var resourcesFilterResult = _app.WaitForElement(combo01).First();
+ var sampleControlResult = _app.WaitForElement(sampleControl).First();
+
+ _app.FastTap(combo01);
+
+ var popupResult = _app.WaitForElement("PopupBorder").First();
+
+ Assert.IsTrue(popupResult.Rect.Width < sampleControlResult.Rect.Width / 2, "The popup should not stretch to the width of the screen");
+ }
}
}
diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
index e8bd08f7ad02..da43b693ab42 100644
--- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
+++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems
@@ -521,6 +521,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -3336,6 +3340,9 @@
ComboBox_DropDownPlacement.xaml
+
+ ComboBox_Stretch.xaml
+
ComboBox_VisibleBounds.xaml
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ComboBox/ComboBox_Stretch.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ComboBox/ComboBox_Stretch.xaml
new file mode 100644
index 000000000000..0558ca3c6c9c
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ComboBox/ComboBox_Stretch.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+ Item 1
+ Item 2 Item 2
+ Item 3 Item 3 Item 3
+ Item 4 Item 4 Item 4 Item 4
+
+
+
+
+
diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ComboBox/ComboBox_Stretch.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ComboBox/ComboBox_Stretch.xaml.cs
new file mode 100644
index 000000000000..c95b0714d3ae
--- /dev/null
+++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ComboBox/ComboBox_Stretch.xaml.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Uno.UI.Samples.Controls;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
+
+namespace UITests.Windows_UI_Xaml_Controls.ComboBox
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ [SampleControlInfo("ComboBox")]
+ sealed partial class ComboBox_Stretch : Page
+ {
+ public ComboBox_Stretch()
+ {
+ this.InitializeComponent();
+ }
+ }
+}
diff --git a/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.cs b/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.cs
index 8dcaaf903955..90d8e9f7aa2e 100644
--- a/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.cs
+++ b/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.cs
@@ -13,6 +13,14 @@ namespace Windows.UI.Xaml.Controls
{
abstract partial class VirtualizingPanelLayout : IScrollSnapPointsInfo
{
+ ///
+ /// Determines if the owner Panel is inside a popup. Used to determine
+ /// if the computation of the breadth should be using the parent's stretch
+ /// modes.
+ /// Related: https://github.com/unoplatform/uno/issues/135
+ ///
+ private bool IsInsidePopup { get; set; }
+
protected enum RelativeHeaderPlacement { Inline, Adjacent }
///
@@ -124,6 +132,11 @@ public bool ShouldBreadthStretch
return true;
}
+ if (IsInsidePopup)
+ {
+ return false;
+ }
+
if (ScrollOrientation == Orientation.Vertical)
{
return XamlParent.HorizontalAlignment == HorizontalAlignment.Stretch;
diff --git a/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.wasm.cs b/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.wasm.cs
index 5d839fbab1fa..3951fee6ced3 100644
--- a/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.wasm.cs
+++ b/src/Uno.UI/UI/Xaml/Controls/ListViewBase/VirtualizingPanelLayout.wasm.cs
@@ -138,6 +138,15 @@ private void OnLoaded(object sender, RoutedEventArgs e)
}
}
+ var hasPopupPanelParent = OwnerPanel.FindFirstParent() != null;
+ var hasListViewParent = OwnerPanel.FindFirstParent() != null;
+ IsInsidePopup = hasPopupPanelParent && !hasListViewParent;
+
+ if (this.Log().IsEnabled(LogLevel.Debug))
+ {
+ this.Log().LogDebug($"Calling {GetMethodTag()} hasPopupPanelParent={hasPopupPanelParent} hasListViewParent={hasListViewParent}");
+ }
+
if (
ItemsControl == null
&& OwnerPanel.TemplatedParent is ItemsControl popupItemsControl
@@ -398,7 +407,7 @@ private Size EstimatePanelSize(bool isMeasure)
if (this.Log().IsEnabled(LogLevel.Debug))
{
- this.Log().LogDebug($"{GetMethodTag()} => {extent} -> {ret} {ScrollOrientation} {_availableSize.Height} {double.IsInfinity(_availableSize.Height)} AvailableBreadth:{AvailableBreadth}");
+ this.Log().LogDebug($"{GetMethodTag()} => {extent} -> {ret} {ScrollOrientation} {_availableSize.Height} {double.IsInfinity(_availableSize.Height)} ShouldBreadthStretch:{ShouldBreadthStretch} XamlParent:{XamlParent} AvailableBreadth:{AvailableBreadth}");
}
return ret;