Bug 35058 - Selecting Entry Controls Within ViewCells Causes FocusChange Cycle
Summary: Selecting Entry Controls Within ViewCells Causes FocusChange Cycle
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 2.3.4
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
: 51807 (view as bug list)
Depends on:
Reported: 2015-10-19 14:57 UTC by Jimmy [MSFT]
Modified: 2018-05-06 12:05 UTC (History)
12 users (show)

Tags: entry viewcell listview focus ac android
Is this bug a regression?: ---
Last known good build:

repro Solution (71.58 KB, application/zip)
2015-10-19 14:57 UTC, Jimmy [MSFT]

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 35058 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:

Description Jimmy [MSFT] 2015-10-19 14:57:49 UTC
Created attachment 13439 [details]
repro Solution

### Overview
When using a ListView that contains ViewCells with an Entry, selecting through the Entry controls will fire off a cycle of several FocusChange events before the destination cell is focused.

I was able to reproduce the issue on both Forms 1.5.0 and 1.5.1-pre2.

Application output: https://gist.github.com/jimmgarrido/2d239d227f674c7acc4e

### Steps to Reproduce 
1. Run the attached solution on Android 5.0+
2. Select “John”
3. Select “James”
4. Select” Mary”

### Actual Results
In the application output, you will see that the app goest through several Focus changed cycles between the selected and previously selected cell until it stays focused on the  selected one.

### Expected Results
FocusChanged is fired on the selected and previously selected cell just once.

### Environment Info
=== Xamarin Studio ===

Version 5.9.7 (build 22)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
	Mono 4.0.4 ((detached/d481017)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400040004

=== Apple Developer Tools ===

Xcode 7.0 (8227)
Build 7A220

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/jimmygarrido/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 1d27ac2
Branch: master
Build date: 2015-09-25 18:08:44-0400

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 509070022
Git revision: 6bd1f169df44ca96addf8a035316c535a4fa46fa
Build date: 2015-09-30 12:30:15-04
Xamarin addins: 1c3e5c0859bdfec0ecd481a57ad6c03bc22f5536

=== Operating System ===

Mac OS X 10.11.0
Darwin Jimmys-MacBook-Pro.local 15.0.0 Darwin Kernel Version 15.0.0
    Wed Aug 26 16:57:32 PDT 2015
    root:xnu-3247.1.106~1/RELEASE_X86_64 x86_64
Comment 1 Jimmy [MSFT] 2015-10-20 20:24:13 UTC
The FocusChange cycle is also causing the Page to go through several Layout cycles as well, which causes performance issues on complex pages.

The issue is also present in the 1.5.2-pre1 release.
Comment 2 Luca 2015-11-05 12:29:36 UTC
I have found this bug too.
I was working on a custom binding of an entry, and I need the unfocused event to make some work...
for Entry outside the listview, it works well...
for Entry inside listview, the unfocus event is called multiple times, even if when you are just typing inside the entry

because is quite urgent for me, do you know when this bug will be fixed?

Comment 3 Dima 2015-11-06 13:35:04 UTC
Temporar solution might be to use Entry inside ScrollView and not ListView. This will solve focus issue, but you will have to deal all the list logic by yourself.
Comment 4 Taylor 2016-04-20 13:56:01 UTC
This is still a problem in forms and it is crippling some of the input validation we are trying to accomplish.

We would appreciate if this issue could get some attention.
Comment 5 Michael 2016-05-04 18:00:21 UTC
This bug is not present when you upgrade to FormsAppCompatActivity.
Comment 6 Dima 2016-05-05 07:13:50 UTC
@Michael Using FormsAppCompatActivity didn't help me. Focus still going crazy after switching from one entry to other.
Comment 7 Taylor 2016-05-05 12:46:01 UTC
@Michael We discovered this issue after we had already upgraded to using the FormsAppCompatActivity.  I can provide a reproduction case if necessary.
Comment 8 Paul DiPietro [MSFT] 2017-03-08 18:52:56 UTC
Still occurring on
Comment 9 otyq08 2017-03-25 14:57:37 UTC
Also have the same problem. 

Posted workaround on StackOverflow helped me. http://stackoverflow.com/questions/42018962/entry-control-focus-unfocus-event-triggering-randomly-inside-listview-in-xamarin

Please fix.
Comment 10 Jimmy [MSFT] 2017-06-19 19:54:25 UTC
*** Bug 51807 has been marked as a duplicate of this bug. ***
Comment 11 David Ortinau [MSFT] 2017-08-30 20:28:28 UTC
Still occurring on
Comment 12 Jitendra Jadav 2017-10-03 06:46:40 UTC
Still occurring on
Comment 13 Alex 2018-01-23 09:08:29 UTC
Still occurring on
Just to clarify, the stackoverflow's workaround don't work because generate some situations where the page layout not refresh since user input (In my case when i add data to and empty ListView), and that's obviously a problem because user can see unupdated data. I'm trying to find a way to force relayout manually, but a new workaroud/fixed release is nedded/appreciated :)
Comment 14 otyq08 2018-05-06 12:05:11 UTC
Ported the issue to github: