diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue9618.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue9618.cs new file mode 100644 index 00000000000..6c3d999ae2e --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue9618.cs @@ -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?"; + }); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 4d2b95a081e..828313e3c89 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -1635,6 +1635,8 @@ + + Issue11333.xaml diff --git a/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs index 5e51b59be09..dee4ddd6823 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/TableViewModelRenderer.cs @@ -160,8 +160,6 @@ public override AView GetView(int position, AView convertView, ViewGroup parent) _restoreFocus = null; } - else if (aview.HasFocus) - aview.ClearFocus(); return layout; }