This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 45277 - On UWP, Entry with IsPassword = true does not allow selection of characters
Summary: On UWP, Entry with IsPassword = true does not allow selection of characters
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.1
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-10-11 14:59 UTC by John Hardman
Modified: 2017-07-14 11:05 UTC (History)
6 users (show)

See Also:
Tags: UWP Entry IsPassword ac
Is this bug a regression?: ---
Last known good build:


Attachments

Description John Hardman 2016-10-11 14:59:20 UTC
Using XF 2.3.1.114, on UWP, an Entry with IsPassword = true does not allow selection of characters.

Typically a keyboard user might do Ctrl+A, Del to quickly delete contents of an Entry, or Ctrl+Home, Ctrl+Shift+End, Del for the same purpose.

Similarly, a mouse user might just swipe the mouse across with the left-button down to do the same thing.

Neither of these work when IsPassword = true.


Easily reproduced, using:

            Entry userPasswordEntry = new Entry
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.StartAndExpand,
                MinimumHeightRequest = 44,
                MinimumWidthRequest = 44
            };
            userPasswordEntry.IsPassword = true;
Comment 1 Paul DiPietro [MSFT] 2017-01-06 16:28:19 UTC
This actually appears to be intended by design.

https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.WinRT/FormsTextBox.cs#L245-L252
Comment 2 John Hardman 2017-01-06 16:45:31 UTC
@Paul DiPietro

The comment in the code is as follows:

// This simulates the "do not allow clipboard copy" behavior the PasswordBox control has

Not allowing clipboard copy is different from not being able to select. The implementation may prevent clipboard copy but it inadvertently prevents select. It should not. Being able to select has use cases other than copying to clipboard.
Comment 3 Paul DiPietro [MSFT] 2017-01-11 19:49:23 UTC
John, I spent some time looking this because the assertion you made is correct although a little complicated. I have no guarantees this will be merged but there's a PR which I believe *mostly* fixes this issue:

https://github.com/xamarin/Xamarin.Forms/pull/677

The behavior as mentioned was presently allowing no selected text, and the current implementation is tricky because of the way that the FormsTextBox works, in that it has a backing Text property and stays synced with the base.Text property. Simply changing the FormsTextBox code so that the selection is allowed isn't an instant fix by itself, as doing something such as entering "123" into the entry, selecting all of it, and then pressing another character like "a" would result in the text being "1". No good. :)

Ultimately what you'll see in that PR is that the SelectionLength is being cached and OnKeyDown is being a bit abused to check against certain key shortcuts like Ctrl-C/X for copy/cut since the regular PasswordBox doesn't allow it. Now, the changes don't fix the fact that the context menu will still enable one to copy the text, but when that's used it only copies the characters as obfuscation characters (the ● character). 

There are also a couple other existing issues that are noted there as well, so I mostly dealt with the matter at hand of selection. The context menu is an issue that might only be fixable on UWP because RT/8.1 doesn't appear to support the use of Clipboard, but I don't think it's the end of the world if it exists as-is for the time being.
Comment 4 Rui Marinho 2017-03-27 17:34:59 UTC
Should be fixed on 2.3.5-pre1
Comment 5 Jacky Waswani 2017-07-14 11:00:20 UTC
Have verified the bug with latest forms build version 2.3.5.256-pre6.

Issue is seems to be fixed with latest build as well.

Screen-cast  : https://www.screencast.com/t/mxEg3ji9

Build Info: https://gist.github.com/GLjackyvaswani/600433ce6f3b92544b42d0392001d326
Comment 6 John Hardman 2017-07-14 11:05:23 UTC
Hi Jacky.

I've noticed a few bug reports where a comment starts "Have verified the bug". This wording suggests confirming the bug exists, not that it is fixed. Could you please use different wording on future bug reports (and ask those around you to do the same), either:

"Confirmed bug exists in version n.n.n.x"

or:

"Tested. Bug appears fixed in version n.n.n.x"

(or similar).

Note You need to log in before you can comment on or make changes to this bug.