Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

axInput should check validation on blur, not on keypress #32

Closed
x1B opened this issue Jun 25, 2014 · 1 comment
Closed

axInput should check validation on blur, not on keypress #32

x1B opened this issue Jun 25, 2014 · 1 comment
Assignees

Comments

@x1B
Copy link
Member

x1B commented Jun 25, 2014

Sometimes, the input validation state and model should not be updated on every keypress, but instead whenever the user tabs out of an input field.

AngularJS 1.3 will ship with ngModelOptions which allows to specify something like { updateOn: "focusout keypress" } per field to achieve this. Because it is very error-prone to have to set this on each ngModel (and still keep things configurable app-by-app), the default should be controlled by a LaxarJS configuration option, and should be picked up by axInput.

@x1B x1B added the bug label Jun 25, 2014
x1B added a commit that referenced this issue Jun 26, 2014
@x1B x1B self-assigned this Jul 3, 2014
x1B added a commit that referenced this issue Jul 4, 2014
 - implemented ngModelOptions.updateOn forward-compatible to AngularJS 1.3
 - implemented configuration option lib.laxar_uikit.controls.input.ngModelOptions to set the global default
x1B added a commit that referenced this issue Jul 4, 2014
* feature/32-check-input-on-blur-not-on-keypress-rebase:
  (#32) Allowed to trigger model updates through user defined events:
   - implemented ngModelOptions.updateOn forward-compatible to AngularJS 1.3
   - implemented configuration option lib.laxar_uikit.controls.input.ngModelOptions to set the global default
@x1B
Copy link
Member Author

x1B commented Jul 4, 2014

Upgrade Information

By default, text input fields using axInput (and by extension ngModel) update their model and validation states on each keypress. It may be desirable to only update a given field – or even all fields within an application – when the user is done editing and changes focus out of the input field.

This can be beneficial to performance and to user experience (the user is not confused with error messages for an incomplete input).

Per-Field Configuration

To change the behavior on a per-field-basis, set the updateOn property of the ngModelOptions attribute. This is a (partial) backport of the corresponding AngularJS 1.3 directive to LaxarJS which uses AngularJS 1.2. The updateOn-property contains a list of events, separated by a single space. The magic event name "default" can be used to indicate that the default events supported by AngularJS should be used.

In this example, the length validation (and the model update) will only be performed when the input field loses focus:

<input type="text" 
       data-ng-model="myModel.myValue" data-ng-model-options="focusout"
       data-ax-input data-ax-input-maximum-length="10">

Global Configuration

To globally override the default provided by AngularJS (update on every keypress), a global default may be set using the configuration option lib.laxar_uikit.controls.input.ngModelOptions.updateOn.

More Information

AngularJS 1.3 will also introduce the property debounce for ngModelOption, which is not supported at this time.

@x1B x1B closed this as completed Jul 4, 2014
x1B added a commit that referenced this issue Jul 4, 2014
x1B added a commit that referenced this issue Jul 4, 2014
x1B added a commit that referenced this issue Jul 4, 2014
* feature/32-check-input-on-blur-not-on-keypress-fix-specs:
  (#32) fixed spec test
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant