|
1 | | -using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes; |
| 1 | +using System.ComponentModel; |
| 2 | +using MaterialDesignThemes.UITests.Samples.AutoSuggestBoxes; |
2 | 3 | using MaterialDesignThemes.UITests.Samples.AutoSuggestTextBoxes; |
3 | 4 | using Xunit.Sdk; |
4 | 5 |
|
@@ -47,7 +48,7 @@ public async Task CanFilterItems_WithSuggestionsAndDisplayMember_FiltersSuggesti |
47 | 48 | public async Task CanChoiceItem_FromTheSuggestions_AssertTheTextUpdated() |
48 | 49 | { |
49 | 50 | await using var recorder = new TestRecorder(App); |
50 | | - |
| 51 | + |
51 | 52 | //Arrange |
52 | 53 | IVisualElement<AutoSuggestBox> suggestBox = (await LoadUserControl<AutoSuggestTextBoxWithTemplate>()).As<AutoSuggestBox>(); |
53 | 54 | IVisualElement<Popup> popup = await suggestBox.GetElement<Popup>(); |
@@ -122,6 +123,41 @@ public async Task CanFilterItems_WithCollectionView_FiltersSuggestions() |
122 | 123 | recorder.Success(); |
123 | 124 | } |
124 | 125 |
|
| 126 | + [Fact] |
| 127 | + [Description("Issue 3761")] |
| 128 | + public async Task AutoSuggestBox_MovesFocusToNextElement_WhenPopupIsClosed() |
| 129 | + { |
| 130 | + await using var recorder = new TestRecorder(App); |
| 131 | + |
| 132 | + // Arrange |
| 133 | + string xaml = """ |
| 134 | + <StackPanel> |
| 135 | + <local:AutoSuggestTextBoxWithCollectionView x:Name="AutoSuggestBoxSample" /> |
| 136 | + <TextBox x:Name="NextTextBox" /> |
| 137 | + </StackPanel> |
| 138 | + """; |
| 139 | + |
| 140 | + IVisualElement<StackPanel> stackPanel = await LoadXaml<StackPanel>(xaml, ("local", typeof(AutoSuggestTextBoxWithCollectionView))); |
| 141 | + var suggestBoxSample = await stackPanel.GetElement<AutoSuggestTextBoxWithCollectionView>("AutoSuggestBoxSample"); |
| 142 | + IVisualElement<AutoSuggestBox> suggestBox = await suggestBoxSample.GetElement<AutoSuggestBox>(); |
| 143 | + IVisualElement<TextBox> nextTextBox = await stackPanel.GetElement<TextBox>("NextTextBox"); |
| 144 | + |
| 145 | + // Act |
| 146 | + await suggestBox.MoveKeyboardFocus(); |
| 147 | + await Task.Delay(50); |
| 148 | + await suggestBox.SendInput(new KeyboardInput("B")); |
| 149 | + await Task.Delay(50); |
| 150 | + await suggestBox.SendInput(new KeyboardInput(Key.Escape)); // Close the popup |
| 151 | + await Task.Delay(50); |
| 152 | + await suggestBox.SendInput(new KeyboardInput(Key.Tab)); // Press TAB to focus the next element (the TextBox) |
| 153 | + await Task.Delay(50); |
| 154 | + |
| 155 | + // Assert |
| 156 | + Assert.True(await nextTextBox.GetIsFocused()); |
| 157 | + |
| 158 | + recorder.Success(); |
| 159 | + } |
| 160 | + |
125 | 161 | private static async Task AssertExists(IVisualElement<ListBox> suggestionListBox, string text, bool existsOrNotCheck = true) |
126 | 162 | { |
127 | 163 | try |
|
0 commit comments