Bug 35483 - ListView scrolls to header when cell tapped
Summary: ListView scrolls to header when cell tapped
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: iOS ()
Version: 1.5.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-11-02 23:13 UTC by Cody Beyer (MSFT)
Modified: 2017-08-30 20:19 UTC (History)
7 users (show)

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

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Cody Beyer (MSFT) 2015-11-02 23:13:06 UTC
### Description 

The following sample demonstrates an issue where tapping an item to change the item source causes a ListView to scroll to the header

### Sample

https://www.dropbox.com/s/v5657rdjiilutag/formslistviewcelldelete.zip?dl=0

### Video

https://www.dropbox.com/s/vd3o206r354b71b/ClickScrollNo.mov?dl=0

### Steps to Reproduce

1. Download sample
2. Deploy to iOS Simulator
3. Scroll to second section (a list of switches) 
4. tap a cell which contains a switch

### Expected Result

Cell should display 'pizza'

### Actual Results

Cell changes to pizza, but also scrolls to top of header

### Versions

=== Xamarin Studio ===

Version 5.10 (build 860)
Installation UUID: 73204efb-3f52-4561-bfd0-1a9af26f9341
Runtime:
	Mono 4.2.1 (explicit/8862921)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010091

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.1 (9079)
Build 7B91b

=== Xamarin.Android ===

Version: 6.0.0.27 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)

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.5
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: 9.2.1.21 (Business Edition)
Hash: 9ce9e8b
Branch: master
Build date: 2015-10-28 19:11:03-0400

=== Xamarin.Mac ===

Version: 2.4.0.105 (Business Edition)

=== Build Information ===

Release ID: 510000860
Git revision: 7c46a0b709d51ad5d5a5ed90a4671cc7b6928e62
Build date: 2015-10-29 17:17:52-04
Xamarin addins: b9337905aca5dc276190d78819728a59cda33a43
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.11.1
Darwin Codys-MacBook-Pro.local 15.0.0 Darwin Kernel Version 15.0.0
    Sat Sep 19 15:53:46 PDT 2015
    root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Comment 2 Sascha Schwegelbauer 2015-11-19 12:13:36 UTC
Same problem here - on iOS, the ListView scrolls to top if items are added.
Using Xamarin.Forms 2.0.0 and iOS 9.1
Comment 3 Sascha Schwegelbauer 2015-11-19 12:20:55 UTC
Edit to my comment: only happens, when IsRefreshing is bound.
Comment 4 buchholz.bastian 2016-05-20 15:45:29 UTC
Same problem here - on iOS, the ListView scrolls to top if items are added and BeginRefresh / EndRefresh is called.
Using Xamarin.Forms 2.2.0.31 and iOS 9.3


var items = new ObservableCollection<string>();
Action addMoreItems = () => {
    var count = 10;
    while (count-- > 0)
        items.Add(items.Count.ToString());
};
addMoreItems();

var list = new ListView();
list.ItemsSource = items;
list.ItemAppearing += (s, e) =>
{
    if (list.IsRefreshing || items[items.Count - 1] != (string)e.Item) return;
    list.BeginRefresh();
    addMoreItems();
    list.EndRefresh();
};
Comment 5 adrianknight89 2016-10-06 16:59:05 UTC
I'm not an iOS expert, but I don't think that's a bug but rather expected behavior. BeginRefresh() or IsRefreshing are meant to be used in pull-to-refresh use case. If you are simply adding items to the collection, do not bother using them.

Probably Android works differently.

Again, maybe I'm wrong, but I'm not sure if I'd use refresh in this scenario.
Comment 6 adrianknight89 2016-10-06 17:01:17 UTC
If XCode / iOS build behaves differently than XF, then we should treat this as a bug.
Comment 7 Shane 2016-10-07 19:44:05 UTC
Not sure if your last comment there is specific to "buchholz.bastian@googlemail.com" or the bug in general.

I brought this up to Xamarin originally last year after I converted a Xamarin iOS project to Xamarin Forms. The original didn't have this issue but when I used a Xamarin Forms list view it did have this issue

also the attached sample

https://www.dropbox.com/s/v5657rdjiilutag/formslistviewcelldelete.zip?dl=0

Doesn't do anything with BeginRefresh or IsRefreshing
Comment 8 David Ortinau [MSFT] 2017-08-30 20:19:03 UTC
I'm not able to reproduce this issue of the ListView changing scroll position using 2.4.0.269-pre2.