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

[Bug] CollectionView unfocuses when CollectionView.Reset is called #13745

Open
GW-FUB opened this issue Feb 12, 2021 · 1 comment
Open

[Bug] CollectionView unfocuses when CollectionView.Reset is called #13745

GW-FUB opened this issue Feb 12, 2021 · 1 comment

Comments

@GW-FUB
Copy link

GW-FUB commented Feb 12, 2021

Description

Hint: Example project linked

I'm using a custom implementation of the ObservableCollection in my code. I'm using it for a search function. I got an entry in my listview header and when I'm entering text the collection changes according to the search results.

My view:
grafik

Since I replaced my listviews with the new collectionview I got a problem:

Whenever I call my ReplaceAll(newItems) method on the collection the entry in the header unfocuses.

Code with my bound items and search:
grafik

My ReplaceAll function:
grafik

I checked the stack trace from the Entry Unfocused event and it seems to get called every time the collection calls CollectionChanged

0xF in COUB.MainPage.EntrySearch_Unfocused at C:\Users\User\Source\Repos\COUB\COUB\MainPage.xaml.cs:31,17	C#

0x13 in Xamarin.Forms.VisualElement.OnUnfocus at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1029,23	C#
0x1C in Xamarin.Forms.VisualElement.OnIsFocusedPropertyChanged at D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:1006,5	C#
0x12E in Xamarin.Forms.BindableObject.SetValueActual at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463,5	C#
0x17C in Xamarin.Forms.BindableObject.SetValueCore at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397,5	C#
0xA in Xamarin.Forms.BindableObject.SetValueCore at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:339,7	C#
0x4 in Xamarin.Forms.Element.SetValueFromRenderer at D:\a\1\s\Xamarin.Forms.Core\Element.cs:254,4	C#
0x5A in Xamarin.Forms.Platform.iOS.EntryRendererBase<UIKit.UITextField>.OnEditingEnded at D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\EntryRenderer.cs:242,4	C#
0x15 in UIKit.UIControlEventProxy.Activated at /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIControl.cs:38,5	C#
0x13 in ObjCRuntime.Messaging.void_objc_msgSend	C#
0x1D in UIKit.UICollectionView.ReloadData at /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UICollectionView.g.cs:736,5	C#
0x77 in Xamarin.Forms.Platform.iOS.ObservableItemsSource.Reload at D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:142,4	C#
0x33 in System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<Xamarin.Forms.Platform.iOS.ObservableItemsSource.<Reload>d__30> at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:316,17	C#
0x25 in Xamarin.Forms.Platform.iOS.ObservableItemsSource.Reload	C#
0x18D in Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged at D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:129,6	C#
0x33 in System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<Xamarin.Forms.Platform.iOS.ObservableItemsSource.<CollectionChanged>d__29> at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:316,17	C#
0x2D in Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged	C#
0xAC in Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged at D:\a\1\s\Xamarin.Forms.Platform.iOS\CollectionView\ObservableItemsSource.cs:108,5	C#
0x33 in System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<Xamarin.Forms.Platform.iOS.ObservableItemsSource.<CollectionChanged>d__28> at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:84,17	C#
0x2D in Xamarin.Forms.Platform.iOS.ObservableItemsSource.CollectionChanged	C#
0x1B in System.Collections.ObjectModel.ObservableCollection<string>.OnCollectionChanged at /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263,21	C#

>	0x6B in COUB.ObservableRangeCollection<string>.ReplaceAll at C:\Users\User\Source\Repos\COUB\COUB\ObservableRangeCollection.cs:29,13	C#
0x65 in COUB.MainPageVm.<get_SearchCommand>b__6_0 at C:\Users\User\Source\Repos\COUB\COUB\MainPageVm.cs:25,13	C#
0x7 in Xamarin.Forms.Command.Execute at D:\a\1\s\Xamarin.Forms.Core\Command.cs:112,4	C#
0x12 in COUB.MainPage.EntrySearch_TextChanged at C:\Users\User\Source\Repos\COUB\COUB\MainPage.xaml.cs:20,13	C#
0x13 in Xamarin.Forms.InputView.OnTextChanged at D:\a\1\s\Xamarin.Forms.Core\InputView.cs:98,4	C#
0x12 in Xamarin.Forms.InputView.<>c.<.cctor>b__49_0 at D:\a\1\s\Xamarin.Forms.Core\InputView.cs:9,55	C#
0x12E in Xamarin.Forms.BindableObject.SetValueActual at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463,5	C#
0x17C in Xamarin.Forms.BindableObject.SetValueCore at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397,5	C#
0x5 in Xamarin.Forms.BindableObject.SetValueCore at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:343,7	C#
0x4 in Xamarin.Forms.Element.SetValueFromRenderer at D:\a\1\s\Xamarin.Forms.Core\Element.cs:248,4	C#
0x3 in Xamarin.Forms.Element.Xamarin.Forms.IElementController.SetValueFromRenderer at D:\a\1\s\Xamarin.Forms.Core\Element.cs:244,92	C#
0x1B in Xamarin.Forms.Platform.iOS.EntryRendererBase<UIKit.UITextField>.OnEditingChanged at D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\EntryRenderer.cs:225,4	C#
0x15 in UIKit.UIControlEventProxy.Activated at /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIControl.cs:38,5	C#
0x66 in UIKit.UIApplication.UIApplicationMain	C#
0xB in UIKit.UIApplication.Main at /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIApplication.cs:86,4	C#
0x11 in UIKit.UIApplication.Main at /Library/Frameworks/Xamarin.iOS.framework/Versions/14.4.1.3/src/Xamarin.iOS/UIKit/UIApplication.cs:65,5	C#
0x8 in COUB.iOS.Application.Main at C:\Users\User\Source\Repos\COUB\COUB.iOS\Main.cs:17,13	C#

I'm pretty sure this is not exspected and it's really annoying. ListView doesn't have this problem and works as exspected.

Steps to Reproduce

Project: https://github.com/GW-FUB/CollectionView_ObservableCollection_Unfocus_Bug

Expected Behavior

Actual Behavior

Basic Information

  • Version with issue: XF 5.0.0.1931
  • Platform Target Frameworks:
    • iOS: 14.4 (Simulator)
    • Android: Unknown
  • NuGet Packages: XF, XE
  • Affected Devices: Simulator, others unknown
@GW-FUB GW-FUB added s/unverified New report that has yet to be verified t/bug 🐛 labels Feb 12, 2021
@hartez hartez added a/collectionview p/iOS 🍎 and removed s/unverified New report that has yet to be verified labels Feb 18, 2021
@valentasm1
Copy link

Any workaround?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants