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

bug($ng): change numberInputType to check for leading decimals - #5682

Closed
joeenzminger wants to merge 4 commits into
angular:masterfrom
joeenzminger:bug_5680
Closed

joeenzminger wants to merge 4 commits into
angular:masterfrom
joeenzminger:bug_5680

Conversation

@joeenzminger

Copy link
Copy Markdown

add check for leading decimal. Some browsers swallow leading decimals on
input type="number".

fixes #5680

add check for leading decimal.  Some browsers swallow leading decimals on
input type="number".

fixes angular#5680
@IgorMinar

Copy link
Copy Markdown
Contributor

I'm sorry, but I wasn't able to verify your CLA signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let me know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@joeenzminger

Copy link
Copy Markdown
Author

CLA Updated to match my GitHub email address

@IgorMinar

Copy link
Copy Markdown
Contributor

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@ghost ghost assigned tbosch Jan 9, 2014
@tbosch

tbosch commented Jan 9, 2014

Copy link
Copy Markdown
Contributor

Hi,
thanks! Could you also add a unit test for this?

@anton000

Copy link
Copy Markdown

status of this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like your IDE screwed up indentation in this file, could you fix that? Should be two spaces.

@caitp caitp self-assigned this Feb 11, 2014
@caitp

caitp commented Feb 11, 2014

Copy link
Copy Markdown
Contributor

@joeenzminger, can you explain what is meant by "swallow leading decimals" for me? This change only modifies values which are exactly one period, and I'm not sure I see why a single '.' shouldn't be NaN.

Now, if this affects more legitimate values, the right fix might be a change to the regexp instead -- actually, looks like the regexp deals with leading periods already.

I'm not sure this really fixes anything, so if you can provide info on the exact problem, I'll be happy to take another look

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A '.' is not a real number, as far as I'm aware. It's also a badInput in modern browsers, which means the value would be the empty string if a user typed it.

@anton000

Copy link
Copy Markdown

@caitp I think he means it doesn't allow the first keyboard entry to be a "." . i.e When entering a decimal value, users usually omit the leading 0 on input, .1234 instead of 0.1234. input [number] seems to reject this type of entry in some browsers.

@joeenzminger

Copy link
Copy Markdown
Author

@caitp - the fix attempt in the PR is not valid (for all browsers anyway). I think I'll pull the PR and submit another one later, but the bug is still valid. I'll also fix the indentation issues.

While '.' is a badInput for type="number", without angular, browsers don't "swallow" it. They continue to display it (even while reporting value as 0 or "") in anticipation of the user continuing to add new characters (and thus making the input valid). With angular, on some browsers, you can't even type the '.', so it is impossible to enter a decimal number unless you first enter a leading 0, etc. This is not very intuitive for most users.

I am also a little stuck on writing a test that validates the fix, since there really isn't a way to validate that affected browsers are displaying the "." with the fix applied (they still report 0 or "" as their value).

@caitp

caitp commented Feb 11, 2014

Copy link
Copy Markdown
Contributor

Ah I see, you're right, FF26 is broken in this way.

@halloffame

Copy link
Copy Markdown
Contributor

@tbosch

tbosch commented Aug 4, 2014

Copy link
Copy Markdown
Contributor

Hi,
we could also try to use input.valueAsNumber for reading out the current value from the browser, instead of reading input.value and the parsing it ourselves...

@caitp

caitp commented Dec 3, 2014

Copy link
Copy Markdown
Contributor

I'm not able to reproduce this anymore in any version of angular I've tried with, in FF33. I think we can close this? Please re-open if this is still an issue.

@caitp caitp closed this Dec 3, 2014
@ghost

ghost commented Jul 15, 2016

Copy link
Copy Markdown

Still facing this issue with angular 1.5.7 and FF 47.0.1.

@ghost ghost unassigned caitp Jul 15, 2016
@gkalpak

gkalpak commented Jul 15, 2016 •

Copy link
Copy Markdown
Member

@credifiable, this issue has been closed. If you still see the problem, please open a new issue providing a live reproduction (e.g. using CodePen, Plnkr etc).

@jjravleuven

Copy link
Copy Markdown

why is this issue closed? it's clearly not dealt with...

@gkalpak

gkalpak commented Jun 18, 2017

Copy link
Copy Markdown
Member

@jamesvanleuven, the issue is still open: #5680

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

input type="number" does not allow numbers with leading decimals on some browsers

9 participants