Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for the Nested Entry View In A Frame Causes Crash #24543

Merged
merged 6 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ protected override void Dispose(bool disposing)
{
var child = GetChildAt(0);
child?.RemoveFromParent();
child?.Dispose();
}

Element?.Handler?.DisconnectHandler();
Expand Down
13 changes: 13 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue15196.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue15196">

<StackLayout x:Name="stackLayout">
<Frame x:Name="frame" HeightRequest="200">
<Entry x:Name="entry" Text="This is entry inside the frame"/>
</Frame>
<Button Text="Remove the frame" AutomationId="RemoveButton" Clicked="OnButtonClicked"/>
</StackLayout>

</ContentPage>
30 changes: 30 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue15196.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 15196, "Nested Entry View In A Frame Causes Crash", PlatformAffected.Android)]
public partial class Issue15196 : ContentPage
{
public Issue15196()
{
InitializeComponent();
}

private void OnButtonClicked(object sender, EventArgs e)
{
if (stackLayout.Children.Contains(frame))
{
stackLayout.Children.Remove(frame);
}

frame?.Handler?.DisconnectHandler();
entry?.Handler?.DisconnectHandler();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#if !MACCATALYST
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
internal class Issue15196 : _IssuesUITest
{
public override string Issue => "Nested Entry View In A Frame Causes Crash";

public Issue15196(TestDevice testDevice) : base(testDevice) { }

[Test]
[Category(UITestCategories.Entry)]
public void NestedEntryViewInFrameShouldNotCrash()
{
App.WaitForElement("RemoveButton");
App.Click("RemoveButton");
}
}
}
#endif
Loading