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

input[type="datetime-local"], the $valid property not set to true on subsequent clearing with button #16500

Closed
piotr-dobrogost opened this issue Mar 21, 2018 · 1 comment

Comments

@piotr-dobrogost
Copy link

I'm submitting a ...

  • [x ] bug report

Current behavior:
When using input[type="datetime-local"] directive without required attribute then clearing input with clear button (blue cross icon) sets $valid property to true only the first time the button is clicked. Subsequent clicks do not set the property to true value anymore.

Expected / new behavior:
Clicking clear button of a control for non-required input[type="datetime-local"] directive should always set $valid property to true.

Minimal reproduction of the problem with instructions:
https://plnkr.co/edit/eFypeLyTVuBi394KhKwR?p=preview
This is version of plunkr from the docs https://docs.angularjs.org/api/ng/input/input%5Bdatetime-local%5D with two modifications: initial Date object is null and attribute required is removed from input[type="datetime-local"].

  1. Enter invalid date (only month for example)
    myForm.input.$valid == false
  2. Click clear button (blue cross icon)
    myForm.input.$valid == true
  3. Enter invalid date (only month for example)
    myForm.input.$valid == false
  4. Click clear button (blue cross icon)
    myForm.input.$valid == false <- should be true instead

AngularJS version: v1.6.10-build.25885+sha.c68b31c (current snapshot)
Browser: Chrome 65.0.3325.162
OS: Fedora 28

@gkalpak
Copy link
Member

gkalpak commented Mar 21, 2018

Closing as duplicate of #14740. It is partly a Chrome issue/idiosyncracy. We could work around it inside AngularJS, but you can work around it in your app too (see #14740 discussion and specific suggestions).

If anyone wants to work on a PR, they are more than welcome 😃

@gkalpak gkalpak closed this as completed Mar 21, 2018
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

2 participants