From 3ffb15cb943f587e9b6042f010e5e67e696707df Mon Sep 17 00:00:00 2001 From: Rui Marinho Date: Fri, 28 Jun 2019 00:34:52 +0100 Subject: [PATCH 1/2] [iOS] Provide a base CarouselViewRenderer (#6686) * [iOS] Don't provide a CarouselViewRenderer * [iOS] Fix CarouselViewRenderer * Update CarouselViewRenderer.cs --- .../CollectionView/CarouselViewRenderer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewRenderer.cs index f8b89da81..96c0ab04b 100644 --- a/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/CollectionView/CarouselViewRenderer.cs @@ -1,10 +1,10 @@ -namespace Xamarin.Forms.Platform.iOS +namespace Xamarin.Forms.Platform.iOS { - public class CarouselViewRenderer + public class CarouselViewRenderer : ItemsViewRenderer { public CarouselViewRenderer() { CollectionView.VerifyCollectionViewFlagEnabled(nameof(CarouselViewRenderer)); } } -} \ No newline at end of file +} From 40961c12b69fd20d593f4653ae2638f279698a4d Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 28 Jun 2019 04:17:11 -0600 Subject: [PATCH 2/2] return empty dictionary instead of null (#6675) fixes #6614 * return empty dictionary instead of null * add warning if Element is being reparented * fix warning message * only fire warning if parent has inner children --- .../Issue6614.cs | 55 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 3 +- Xamarin.Forms.Core/Element.cs | 6 ++ Xamarin.Forms.Core/TabIndexExtensions.cs | 7 ++- 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6614.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6614.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6614.cs new file mode 100644 index 000000000..48cfd5e7f --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6614.cs @@ -0,0 +1,55 @@ +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, 6614, "[Android] Tabindex Calculation crashing when calculating on Layout", PlatformAffected.Android)] + public class Issue6614 : TestContentPage + { + Button _button = null; + + string _instruction1 = "Turn on Screen Reader and click me."; + protected override void Init() + { + _button = new Button() + { + Text = _instruction1, + Command = new Command(() => + { + if(Content is ContentView currentContentView) + { + var currentContent = currentContentView.Content; + currentContentView.Content = null; + this.Content = currentContent; + _button.Text = "Success"; + } + else + { + var currentContent = this.Content; + var contentView = new ContentView(); + this.Content = contentView; + contentView.Content = currentContent; + _button.Text = "Click me one more time"; + } + }), + TabIndex = 1 + }; + + Content = new StackLayout() + { + Children = + { + _button + } + }; + } + } +} 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 5957faed3..2b4a008d8 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 @@ -948,6 +948,7 @@ + @@ -1227,7 +1228,7 @@ Designer - MSBuild:Compile + MSBuild:UpdateDesignTimeXaml \ No newline at end of file diff --git a/Xamarin.Forms.Core/Element.cs b/Xamarin.Forms.Core/Element.cs index 5149f35bc..cfbcf46be 100644 --- a/Xamarin.Forms.Core/Element.cs +++ b/Xamarin.Forms.Core/Element.cs @@ -187,7 +187,13 @@ namespace Xamarin.Forms OnPropertyChanging(); if (RealParent != null) + { ((IElement)RealParent).RemoveResourcesChangedListener(OnParentResourcesChanged); + + if(value != null && (RealParent is Layout || RealParent is IControlTemplated)) + Log.Warning("Element", $"{this} is already a child of {RealParent}. Remove {this} from {RealParent} before adding to {value}."); + } + RealParent = value; if (RealParent != null) { diff --git a/Xamarin.Forms.Core/TabIndexExtensions.cs b/Xamarin.Forms.Core/TabIndexExtensions.cs index c167b48bf..1bd0c0c4c 100644 --- a/Xamarin.Forms.Core/TabIndexExtensions.cs +++ b/Xamarin.Forms.Core/TabIndexExtensions.cs @@ -16,7 +16,7 @@ namespace Xamarin.Forms { countChildrensWithTabStopWithoutThis = 0; - Element parentPage = (element as NavigableElement).Parent; + Element parentPage = (element as Element)?.Parent; while (parentPage != null && !(parentPage is Page)) parentPage = parentPage.Parent; @@ -26,7 +26,7 @@ namespace Xamarin.Forms descendantsOnPage = shell.Items; if (descendantsOnPage == null) - return null; + return new Dictionary>(); var childrensWithTabStop = new List(); foreach (var descendant in descendantsOnPage) @@ -34,8 +34,9 @@ namespace Xamarin.Forms if (descendant is ITabStopElement visualElement && visualElement.IsTabStop) childrensWithTabStop.Add(visualElement); } + if (checkContainsElement && !childrensWithTabStop.Contains(element)) - return null; + return new Dictionary>(); countChildrensWithTabStopWithoutThis = childrensWithTabStop.Count - 1; return childrensWithTabStop.GroupToDictionary(c => c.TabIndex);