Skip to content

Commit

Permalink
[WASM] Fix multiple popup display
Browse files Browse the repository at this point in the history
Fix bug preventing ComboBox from displaying when inside ContentDialog. (Multiple popups beyond the first weren't being measured.)
  • Loading branch information
davidjohnoliver committed Sep 23, 2019
1 parent 3a14ecd commit 65e3e8e
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/ReleaseNotes/_ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
* [Wasm] Fix unloaded UIElements are made visible if measured and arranged
* [Android] Fix java NRE handing touch events on detached view
* #1557 Fix local DataContext on ContentDialog is overwritten
* [WASM] Fix display for multiple popups (eg ComboBox inside of ContentDialog)

## Release 1.45.0
### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,27 @@ public void ContentDialog_Closing_Result()
_app.WaitForDependencyPropertyValue(resultText, "Text", "Primary");
_app.WaitForDependencyPropertyValue(closedText, "Text", "Closed");
}

[Test]
[AutoRetry]
public void ContentDialog_ComboBox()
{
Run("UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests.ContentDialog_ComboBox");

var showDialog = _app.Marked("ShowComboBoxDialog");
_app.WaitForElement(showDialog);
_app.Tap(showDialog);

var comboBox = _app.Marked("InnerComboBox");
_app.WaitForElement(comboBox);
_app.Tap(comboBox);

var item = _app.Marked("ComboElement4");
_app.WaitForElement(item);
_app.Tap(item);

var resultsText = _app.Marked("ResultsTextBlock");
_app.WaitForDependencyPropertyValue(resultsText, "Text", "Item 4");
}
}
}
14 changes: 14 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ComboBoxContentDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ContentDialog_Closing.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ContentDialog_ComboBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentPresenter\ContentPresenter_Background.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -2585,9 +2593,15 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentControlTestsControl\ContentControl_UnsetContent.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentControlTestsControl\ContentControl_WithInlineContent.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentControlTestsControl\ContentControl_WithPadding.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ComboBoxContentDialog.xaml.cs">
<DependentUpon>ComboBoxContentDialog.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ContentDialog_Closing.xaml.cs">
<DependentUpon>ContentDialog_Closing.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ContentDialog_ComboBox.xaml.cs">
<DependentUpon>ContentDialog_ComboBox.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ContentDialog_Simple.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentDialogTests\ContentDialog_Simple_Dialog.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ContentPresenter\ContentPresenter_Background.xaml.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<UserControl x:Class="UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests.ComboBoxContentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<Grid>
<ComboBox x:Name="InnerComboBox"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
<TextBlock x:Name="ComboElement1"
Text="Item 1" />
<TextBlock x:Name="ComboElement2"
Text="Item 2" />
<TextBlock x:Name="ComboElement3"
Text="Item 3" />
<TextBlock x:Name="ComboElement4"
Text="Item 4" />
<TextBlock x:Name="ComboElement5"
Text="Item 5" />
</ComboBox>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
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 User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests
{
public sealed partial class ComboBoxContentDialog : UserControl
{
public ComboBoxContentDialog()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<UserControl x:Class="UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests.ContentDialog_ComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">

<StackPanel>
<Button x:Name="ShowComboBoxDialog"
Content="Show dialog"
Click="ShowComboBoxDialog_Click" />
<TextBlock x:Name="ResultsTextBlock"
Text="{Binding Path=SelectedItemText, FallbackValue=NoResult}" />
<TextBlock Text="UnoTestbed4"
Margin="50" />
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Uno.UI.Samples.Controls;
using Uno.UI.Samples.UITests.Helpers;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
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 User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

namespace UITests.Shared.Windows_UI_Xaml_Controls.ContentDialogTests
{
[SampleControlInfo("ContentDialog", "ContentDialog_Closing", description: "ContentDialog with a ComboBox inside")]
public sealed partial class ContentDialog_ComboBox : UserControl
{
public ContentDialog_ComboBox()
{
this.InitializeComponent();
}

private void ShowComboBoxDialog_Click(object sender, RoutedEventArgs e)
{
var viewModel = new ComboBoxDialogViewModel(Dispatcher);
var dialog = new ContentDialog
{
Content = new ComboBoxContentDialog(),
DataContext = viewModel,
CloseButtonText = "Done"
};

ResultsTextBlock.DataContext = viewModel;
var dummy = dialog.ShowAsync();
}

public class ComboBoxDialogViewModel : ViewModelBase
{
public ComboBoxDialogViewModel(CoreDispatcher dispatcher) : base(dispatcher)
{

}

private object _selectedItem;
public object SelectedItem
{
get => _selectedItem;
set
{
if (!Equals(_selectedItem, value))
{
_selectedItem = value;
RaisePropertyChanged();
if (value is TextBlock)
{
RaisePropertyChanged(nameof(SelectedItemText));
}
}
}
}

public object SelectedItemText => (SelectedItem as TextBlock)?.Text;
}
}
}
17 changes: 16 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/Popup/PopupRoot.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,27 @@ private void PopupRoot_PointerReleased(object sender, Input.PointerRoutedEventAr
.OfType<PopupPanel>()
.LastOrDefault(p => p.Popup.IsLightDismissEnabled);

if(lastDismissablePopupPanel != null)
if (lastDismissablePopupPanel != null)
{
lastDismissablePopupPanel.Popup.IsOpen = false;
}
}

protected override Size MeasureOverride(Size availableSize)
{
Size size = default;
foreach (var child in Children)
{
if (!(child is PopupPanel))
{
continue;
}
// Note that we should always be arranged with the full size of the window, so we don't care too much about the return value here.
size = MeasureElement(child, availableSize);
}
return size;
}

protected override Size ArrangeOverride(Size finalSize)
{
foreach (var child in Children)
Expand Down

0 comments on commit 65e3e8e

Please sign in to comment.