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

* Committed the changes of the issue

* properly fixed the Object disposed exception

* Added the proper name of test case

* Removing the unneccesary space

* fix-15196-Removed the Dispose method.

* fix-15196-Modified and removed the changes in test case and sample.

---------

Co-authored-by: AhamedAliNishad <ahamedalinishad.j@syncfusion.com>
This commit is contained in:
BagavathiPerumal 2024-09-11 01:00:10 +05:30 коммит произвёл GitHub
Родитель dc27b9c395
Коммит 64343f5182
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 66 добавлений и 1 удалений

Просмотреть файл

@ -131,7 +131,6 @@ namespace Microsoft.Maui.Controls.Handlers.Compatibility
{
var child = GetChildAt(0);
child?.RemoveFromParent();
child?.Dispose();
}
Element?.Handler?.DisconnectHandler();

Просмотреть файл

@ -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>

Просмотреть файл

@ -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();
}
}
}

Просмотреть файл

@ -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