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

fix(input.min/max) re-validate input[type=number] when min/max changes #6369

Closed
wants to merge 1 commit into from

Conversation

quazzie
Copy link
Contributor

@quazzie quazzie commented Feb 20, 2014

Value was not re-evaluated when min/max changed.

Value was not re-evaluated when min/max changed.
@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#6369)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@njs50
Copy link

njs50 commented Apr 1, 2014

If this isn't going to be merged soon it might be worthwhile updating the docs to note that the expected behaviour doesn't work?

@tbosch
Copy link
Contributor

tbosch commented Apr 2, 2014

We are working on refactoring the forms validation, see #6928.

@njs50
Copy link

njs50 commented Apr 2, 2014

Nice!

If it does slip from 1.3 it would be nice to have this PR in the meantime.

@greglockwood
Copy link

It appears that this PR does not address a related issue where if the value for the min/max attribute is "" (empty string) when the input is compiled, but changes to a valid number later, then the validator functions are never added correctly, even when the attribute value changes.

This is because of the if (attr.min) / if (attr.max) conditions that will evaluate as false if the attribute value is initially blank.

This is most easily observed if you try to use an interpolated expression as the value for the min/max attributes where the expression initially evaluates to undefined but in a subsequent cycle evaluates to a number:
e.g. <input type="number" ng-model="some.property" min="{{ somePropMetaData.min }}"> where $scope.somePropMetaData gets set after the input has been compiled.

There is a workaround where you ensure that a non-empty value is initially set for the min/max attribute so the if condition passes:
<input type="number" ng-model="some.property" min="{{ somePropMetaData ? somePropMetaData.min : 0}}">
but it is not clear from the documentation that such a workaround is required and it requires close examination of the source code to notice that it is.

@Narretz
Copy link
Contributor

Narretz commented Jul 4, 2014

Last remnants of this issue are discussed here: #2404

@Narretz Narretz closed this Jul 4, 2014
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.

6 participants