Bug 42534 - Setting SetSelectAllOnFocus(true) on Custom Entry Does Not Always Work
Summary: Setting SetSelectAllOnFocus(true) on Custom Entry Does Not Always Work
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-07-13 18:50 UTC by Jimmy [MSFT]
Modified: 2018-05-06 13:12 UTC (History)
5 users (show)

Tags: ac
Is this bug a regression?: No
Last known good build:

repro project (47.97 KB, application/zip)
2016-07-13 18:50 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 42534 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] 2016-07-13 18:50:43 UTC
Created attachment 16652 [details]
repro project

### Overview
When using a custom Entry renderer for Entry controls inside a ListView, setting SetSelectAllOnFocus(true) does not work for some of the Entry controls.  

It works fine for the Entry controls that are rendered when the initial ListView cells are rendered. It's the new cells that get rendered when the list is scrolled that experience the issue. Oddly though, it only happens the first time they are selected. If the Entry is selected again, then it works. 

I noticed that the Entries that were having the issue did not have a null e.OldElement. I looked at the Forms source and noticed: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Renderers/EntryRenderer.cs#L58

### Workaround
Calling the following seems to fix the issue:

if(e.OldElement != null)

### Steps to Reproduce
1. Run the attached project
2. Press on one of the initial Entries
3. Scroll the List and press on the Entry of a newer cells

### Expected Results
Pressing Entry will highlight all the text inside the control. 

### Actual Results
Pressing one of the initial Entries selects all its text. However, in the newer Entries, it will not select any text and just show the cursor.

### Testing Info
 Tested using Forms and
Comment 1 adrianknight89 2016-10-16 05:01:37 UTC
See https://github.com/xamarin/Xamarin.Forms/pull/462
Comment 2 adrianknight89 2017-01-02 23:17:44 UTC
I noticed that SetSelectAllOnFocus(true) does not work at all in AdjustResize.
Comment 3 otyq08 2018-05-06 13:12:25 UTC
Ported issue to GitHub: