Bug 36398 - Removing element from ObservableCollection as ItemSource in ListView with sections duplicate in a weird way the last section title in iOS
Summary: Removing element from ObservableCollection as ItemSource in ListView with sec...
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: All Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-11-30 21:17 UTC by Samuel R. Magny
Modified: 2017-09-01 03:21 UTC (History)
9 users (show)

Tags: ac, listview, ios, retest
Is this bug a regression?: ---
Last known good build:


Attachments
Captures from my iPad (625.67 KB, application/zip)
2015-11-30 21:17 UTC, Samuel R. Magny
Details
Project who demonstrate the problem on iOS (416.06 KB, application/octet-stream)
2016-01-14 14:56 UTC, Samuel R. Magny
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 36398 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Samuel R. Magny 2015-11-30 21:17:23 UTC
Created attachment 14044 [details]
Captures from my iPad

When removing the last elements (first, second or third) in the last section of the ListView, the last section title header is draw over the last cells. It only happen on iPad and it happen on iOS 9.1 with Xamarin Forms 2.0.0, Xamarin.iOS 9.2.1.51.

The ItemSource of the listView must all be ObservableCollection.


public class MyClass {
...
public ObservableCollection< SectionModel > Source;
...

//I'm doing these action on the ItemSource to make the bug happen:
void removeFromLastSection (int sectionIndex, int rowIndex) {
   var section = Source.ElementAt (sectionIndex);
   var object = section.ElementAt (rowIndex);
   ...
   section.RemoveAt (rowIndex);
   SectionModel lastSection = Source.Last();
   lastSection.Add(object);
}

...

//Section
public class SectionModel : ObservableCollection<TestConfig> {
   public static readonly Binding GroupTitleBinding = new Binding("SectionTitle");
   public string SectionTitle { get; set; }

   public SectionModel(string title) {
      SectionTitle = title;
   }
}

}
Comment 1 Rajneesh Kumar 2016-01-12 16:55:20 UTC
I tried to reproduce this issue but not sure about the steps, that result unable to reproduce this. 

Could you please share a small sample application that demonstrate this issue. That would be very helpful to reproduce this issue at our end.

Thanks..!
Comment 2 Samuel R. Magny 2016-01-14 14:56:38 UTC
Created attachment 14587 [details]
Project who demonstrate the problem on iOS

You'll need to download NuGet packages to make it work.
Comment 3 Samuel R. Magny 2016-01-14 14:58:07 UTC
Hi Rajneesh Kumar,

I've added a Xamarin Studio project with a quick demo to reproduce the problem. You simply have to play with the (-) and (+) buttons in edit mode.

Thank you!
Comment 4 Rajneesh Kumar 2016-01-15 15:33:39 UTC
I have checked this issue with the attached test sample, provided in comment 2. When I simply play with the (-) and (+) buttons in edit mode, I observed that sections duplicate in a weird way. 

Screencast: http://www.screencast.com/t/QSlCMNKlhp

Please have a look on the screencast and let me confirmed that this is the same behavior you are facing at you end.

Thanks..! 

Ide Logs: https://gist.github.com/Rajneesh360Logica/d2d76170a43b1feffe13
Build output: https://gist.github.com/Rajneesh360Logica/a983001f8710c41f1c9c

Environment Info:


=== Xamarin Studio ===

Version 5.10.2 (build 51)
Installation UUID: 229ec167-a154-47bf-bb8b-10fe36c1ad41
Runtime:
	Mono 4.2.2 (explicit/b8ca425)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402020028

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.2 (9548)
Build 7C68

=== Xamarin.iOS ===

Version: 9.4.1.21 (Business Edition)
Hash: c71a120
Branch: master
Build date: 2016-01-12 14:45:43-0500

=== Xamarin.Android ===

Version: 6.0.1.9 (Business Edition)
Android SDK: /Users/360_macmini/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23.0.1

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.1
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.4.1.5 (Business Edition)

=== Build Information ===

Release ID: 510020051
Git revision: 36453d5e06a1ad2cc8d261ad32e29abe0ed57c1f
Build date: 2016-01-12 17:33:10-05
Xamarin addins: ab25321e8918350655a7d46c86cfbaac3222fd3c
Build lane: monodevelop-lion-cycle6-c6sr1

=== Operating System ===

Mac OS X 10.11.2
Darwin 360-MACMINIs-Mac-mini.local 15.2.0 Darwin Kernel Version 15.2.0
    Fri Nov 13 19:56:56 PST 2015
    root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64
Comment 5 Samuel R. Magny 2016-01-15 15:40:32 UTC
Yes that's it!
But, there is one more thing that happen with this bug. At the end, when there are duplicated section headers. If you press "Done" to exit editing mode, headers will stay in the TableView.

Thanks!
Comment 6 Rajneesh Kumar 2016-01-15 15:48:24 UTC
@Samuel thanks a lot for the test sample and confirmation of issue.

I have checked this again and I observed that sections duplicate in a weird way, and if I I press "Done" to exit editing mode, headers will stay in the TableView.

Screencast: http://www.screencast.com/t/w0Ee4ffvX

Hence I am changing its status to Confirmed.

Thanks..!
Comment 7 Samuel R. Magny 2016-02-11 20:53:09 UTC
I've just found a workaround for this bug!

When editing the ObservableCollection, if you remove a element after adding it the bug will not happen.
Ex: (var name are defined in the first post)


//The bug will happen
void SwitchObjectAtIndex (int sectionIndex, int rowIndex) {
   var section = Source.ElementAt (sectionIndex);
   var object = section.ElementAt (rowIndex);
   ...
   section.RemoveAt (rowIndex);
   SectionModel lastSection = Source.Last();
   lastSection.Add(object);
}



//The bug will NOT happen!
void SwitchObjectAtIndex (int sectionIndex, int rowIndex) {
   var section = Source.ElementAt (sectionIndex);
   var object = section.ElementAt (rowIndex);
   ...
   
   SectionModel lastSection = Source.Last();
   lastSection.Add(object);      
   section.RemoveAt (rowIndex);   // <----- Change this function place
}