Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

password input fields inconsistant with angular values #8230

Closed
EvanLomas opened this issue Jul 17, 2014 · 7 comments
Closed

password input fields inconsistant with angular values #8230

EvanLomas opened this issue Jul 17, 2014 · 7 comments

Comments

@EvanLomas
Copy link

~~ Issue 1 ~~
While writing a simple login window I've noticed that adding trailing spaces to password input fields causes the data stored in angular to only trim the stored value, but not correct the HTML5 input field.

for example, typing = "1" (replacing _ with spaces)
will result in the ng-model value being = "1"
but the field visible to the user will show "●●●●●●●●●●●●●●●●●"
Which is inconsistent and misleading to a user

~~ Issue 2 ~~
A different (but likely related) bug I've found is that repeating spaces within the password produces inconsistency in the stored data and it's variable itself

for example, typing = "1________1" (replacing _ with spaces)
will result in the ng-model value being = "1_1" (replacing _ with spaces)
but the ng-model ".length" attribute will be "10", not the expected "3"

@matsko
Copy link
Contributor

matsko commented Jul 17, 2014

@caitp mind taking a look at this one?

@caitp
Copy link
Contributor

caitp commented Jul 17, 2014

I think the solution to ~~ Issue 1 ~~ is really just "use ng-trim=false", but I can't actually reproduce the second issue at all. "1         1" with or without ng-trim=false will still have a length of 10 (not 3), and the model value won't be "1 1" (it's not clear why it would be expected to be, trimming whitespace only removes leading and trailing whitespace, not interior whitespace)

I think this actually works as expected here

@caitp
Copy link
Contributor

caitp commented Jul 17, 2014

@zeus3rd can you please provide an actual reproduction to show the issue you're having? thanks

@Narretz Narretz added this to the Purgatory milestone Jul 17, 2014
@EvanLomas
Copy link
Author

After further investigation, seems Issue 2 is an expected result of using {{}} to display text. However issue 1 is still valid as my example below shows:

http://jsfiddle.net/zeus3rd/eAqC4/2/

@caitp
Copy link
Contributor

caitp commented Jul 18, 2014

you're using ng-trim="true" ... you're essentially saying "yes, I want leading and trailing whitespace to be trimmed". true is also the default value of ngTrim, so you need to say ng-trim="false" for this to behave differently.

@caitp
Copy link
Contributor

caitp commented Jul 18, 2014

Anyways, it may be bad that it's the default behaviour for password inputs --- I guess we could change the behaviour of textInputType to use a default of false for password inputs.

@caitp
Copy link
Contributor

caitp commented Jul 18, 2014

I'm not sure what others would think about that change, but I can implement that.

@btford btford removed the gh: issue label Aug 20, 2014
@caitp caitp closed this as completed in a7fb357 Aug 21, 2014
caitp added a commit that referenced this issue Aug 21, 2014
Do not trim input[type=password] values

BREAKING CHANGE:

Previously, input[type=password] would trim values by default, and would require an explicit ng-trim="false"
to disable the trimming behaviour. After this CL, ng-trim no longer effects input[type=password], and will
never trim the password value.

Closes #8250
Closes #8230

Conflicts:
	src/ng/directive/input.js
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants