material icon indicating copy to clipboard operation
material copied to clipboard

Form submits wrong date because md-datepicker is slow to update model date

Open horduringi opened this issue 9 years ago • 1 comments

Actual Behavior:

  • What is the issue? * When using md-datepicker inside a form with ng-submit it is possible to change the date and submitting the form before the model value has updated. The old date is submitted.
  • What is the expected behavior? It is expected that once a value in md-datepicker is updated that the form would submit the updated value.

CodePen (or steps to reproduce the issue): *

  • CodePen Demo which shows your issue: https://codepen.io/horduringi/pen/EXpzwL
  • Details: Information on how to reproduce the bug are included in pen.
  1. Change date with keyboard.
  2. Press enter or submit by clicking before model date has changed.
  3. Observe that submitted date is different from datepicker and model date (finally updated).

AngularJS Versions: *

  • AngularJS Version: 1.6.5
  • AngularJS Material Version: 1.1.4

Additional Information:

  • Browser Type: * Chrome
  • Browser Version: * 59.0.3071.115 (Official Build) (64-bit) (cohort: Stable)
  • OS: * Windows 10
  • Stack Traces: N/A

Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

horduringi avatar Jul 06 '17 18:07 horduringi

Cause:

Default value for debounceInterval is 500ms, as stated in the documentation: https://material.angularjs.org/latest/api/directive/mdDatepicker

Solution:

Set md-debounce-interval="0" on datepicker. I updated the pen to demonstrate the problem and solution.

This issue may be closed.

horduringi avatar Jul 06 '17 19:07 horduringi