-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from WCKYWCKF/A-few-minor-issues
Fixed: Closing a dialog returns TView to the user instead of occupying its parent.
- Loading branch information
Showing
4 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...s/HeadlessTest.Ursa/Controls/OverlayShared/Case_Close_Dialog_Clear_Content_Parent/Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Headless; | ||
using Avalonia.Headless.XUnit; | ||
using Avalonia.Input; | ||
using Avalonia.Threading; | ||
|
||
namespace HeadlessTest.Ursa.Controls.OverlayShared.Case_Close_Dialog_Clear_Content_Parent; | ||
|
||
public class Test | ||
{ | ||
[AvaloniaFact] | ||
public void Dialog_Parent_Is_Cleared_After_Close() | ||
{ | ||
var ursaWindow = new TestWindow(); | ||
ursaWindow.Show(); | ||
var button = ursaWindow.FindControl<Button>("button"); | ||
ursaWindow.MouseDown(new Point(280, 400), MouseButton.Left); | ||
ursaWindow.MouseUp(new Point(280, 400), MouseButton.Left); | ||
Dispatcher.UIThread.RunJobs(); | ||
var parent = ursaWindow.TextBox.Parent; | ||
Assert.NotNull(ursaWindow.TextBox.Parent); | ||
ursaWindow.DialogViewModel.Close(); | ||
Dispatcher.UIThread.RunJobs(); | ||
Assert.Null(ursaWindow.TextBox.Parent); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...sTest.Ursa/Controls/OverlayShared/Case_Close_Dialog_Clear_Content_Parent/TestWindow.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<u:UrsaWindow xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:u="https://irihi.tech/ursa" | ||
mc:Ignorable="d" d:DesignWidth="800" | ||
d:DesignHeight="450" | ||
x:Class="HeadlessTest.Ursa.Controls.OverlayShared.Case_Close_Dialog_Clear_Content_Parent.TestWindow" | ||
Title="TestWindow"> | ||
<Button HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="button" Content="Click" Click="Button_OnClick"></Button> | ||
</u:UrsaWindow> |
32 changes: 32 additions & 0 deletions
32
...st.Ursa/Controls/OverlayShared/Case_Close_Dialog_Clear_Content_Parent/TestWindow.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Interactivity; | ||
using Irihi.Avalonia.Shared.Contracts; | ||
using Ursa.Controls; | ||
|
||
namespace HeadlessTest.Ursa.Controls.OverlayShared.Case_Close_Dialog_Clear_Content_Parent; | ||
|
||
public partial class TestWindow : UrsaWindow | ||
{ | ||
public TestWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
internal TextBox TextBox = new TextBox(); | ||
internal DialogViewModel DialogViewModel = new DialogViewModel(); | ||
|
||
private void Button_OnClick(object? sender, RoutedEventArgs e) | ||
{ | ||
OverlayDialog.Show(TextBox, DialogViewModel); | ||
} | ||
} | ||
|
||
class DialogViewModel : IDialogContext | ||
{ | ||
public void Close() | ||
{ | ||
RequestClose?.Invoke(this, null); | ||
} | ||
|
||
public event EventHandler<object?>? RequestClose; | ||
} |