Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixing issue with ComboBoxes in dialog host
This revert the fix that was done for #3249.
Need to revisit fix that was done and find an alternative.
  • Loading branch information
Keboo committed Feb 8, 2024
commit 9b789991b489beb6483508e584cb7d2ed0b1cbf0
38 changes: 38 additions & 0 deletions MaterialDesignThemes.UITests/Samples/DialogHost/WithComboBox.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<UserControl x:Class="MaterialDesignThemes.UITests.Samples.DialogHost.WithComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MaterialDesignThemes.UITests.Samples.DialogHost"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">

<materialDesign:DialogHost x:Name="SampleDialogHost"
Loaded="DialogHost_Loaded">
<materialDesign:DialogHost.DialogContent>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="Please choose the desired targeted platform "
Margin="6"
FontSize="12"
TextWrapping="Wrap"/>
<ComboBox
x:Name="TargetedPlatformComboBox"
Grid.Row="1"
Width="120"
materialDesign:HintAssist.HelperText="Targetted Platform"
Style="{StaticResource MaterialDesignFloatingHintComboBox}">
<ComboBoxItem Content="Item1"/>
<ComboBoxItem Content="Item2" x:Name="TargetItem"/>
<ComboBoxItem Content="Item3"/>
</ComboBox>

</Grid>
</materialDesign:DialogHost.DialogContent>
</materialDesign:DialogHost>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace MaterialDesignThemes.UITests.Samples.DialogHost;

/// <summary>
/// Interaction logic for WithComboBox.xaml
/// </summary>
public partial class WithComboBox : UserControl
{
public WithComboBox()
{
InitializeComponent();
}

private void DialogHost_Loaded(object sender, RoutedEventArgs e)
{
SampleDialogHost.IsOpen = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public async Task OnEditableComboBox_ClickInTextArea_FocusesTextBox()
var editableTextBox = await comboBox.GetElement<TextBox>("PART_EditableTextBox");
var button = await stackPanel.GetElement<Button>("Button");

// Open the combobox initially
// Open the ComboBox initially
await comboBox.LeftClick(Position.RightCenter);
await Task.Delay(50); // Allow a little time for the drop-down to open (and property to change)
bool wasOpenAfterClickOnToggleButton = await comboBox.GetIsDropDownOpen();
Expand Down
26 changes: 26 additions & 0 deletions MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,32 @@ public async Task DialogHost_ChangesSelectedRailItem_DoesNotPerformRailChangeWhe
Assert.True(await railItem1.GetIsSelected());
Assert.False(await railItem2.GetIsSelected());

recorder.Success();
}

[Fact]
[Description("Issue 3450")]
public async Task DialogHost_WithComboBox_CanSelectItem()
{
await using var recorder = new TestRecorder(App);

IVisualElement dialogHost = await LoadUserControl<WithComboBox>();

var comboBox = await dialogHost.GetElement<ComboBox>("TargetedPlatformComboBox");
await Task.Delay(500);
await comboBox.LeftClick();

var item = await Wait.For(() => comboBox.GetElement<ComboBoxItem>("TargetItem"));
await Task.Delay(TimeSpan.FromSeconds(1));
await item.LeftClick();

await Wait.For(async () =>
{
var index = await comboBox.GetSelectedIndex();
Assert.Equal(1, index);
});


recorder.Success();
}
}
2 changes: 1 addition & 1 deletion MaterialDesignThemes.Wpf/DialogHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ private void OnPreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventA
if (_popup != null &&
PresentationSource.FromVisual(_popup.Child) is HwndSource hwndSource)
{
SetFocus(hwndSource.Handle);
//SetFocus(hwndSource.Handle);
}
}

Expand Down