Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Android - Fix for losing focus in Editor when Table View's Table Section Changes #11518

Closed
wants to merge 5 commits into from
Closed
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
@@ -0,0 +1,60 @@
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 9618, "[Bug] Changing Text of TableSection changes focus.", PlatformAffected.All)]
public class Issue9618 : TestContentPage
{
public TableSection TableSectionToChange { get; set; }
public Editor EditorToFocus { get; set; }

protected override void Init()
{

var tableView = new TableView();
var tableRoot = new TableRoot();

TableSectionToChange = new TableSection() { Title = "Change me" };
var firstViewCell = new ViewCell();
firstViewCell.View = new Label() { Text = "Hello" };

TableSectionToChange.Add(firstViewCell);

var editorTableSection = new TableSection() { Title = "Editor Title" };
var editorViewCell = new ViewCell();
EditorToFocus = new Editor();

editorViewCell.View = EditorToFocus;
editorTableSection.Add(editorViewCell);

tableRoot.Add(TableSectionToChange);
tableRoot.Add(editorTableSection);
tableView.Root = tableRoot;

Content = tableView;
}

protected override void OnAppearing()
{
base.OnAppearing();

Device.BeginInvokeOnMainThread(async () =>
{
EditorToFocus.Focus();

await Task.Delay(4000);

TableSectionToChange.Title = "Did I really lose focus?";
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,8 @@
<Compile Include="$(MSBuildThisFileDirectory)Issue11291.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11244.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11272.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue9618.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11333.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue11333.xaml.cs">
<DependentUpon>Issue11333.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ public override AView GetView(int position, AView convertView, ViewGroup parent)

_restoreFocus = null;
}
else if (aview.HasFocus)
aview.ClearFocus();

return layout;
}
Expand Down