brianblakely / nodep-date-input-polyfill

Automatically adds datepickers to input[type=date] on IE, macOS Safari, and legacy browsers.
https://www.npmjs.com/package/nodep-date-input-polyfill
MIT License
96 stars 137 forks source link

Value is not set if date is typed in manually #41

Closed vleong2332 closed 7 years ago

vleong2332 commented 7 years ago

In Firefox, if I type in the date manually instead of using the picker, the <input> value is not updated regardless of whether or not the typed-in date is in valid yyyy-MM-dd format.

brianblakely commented 7 years ago

tl;dr - Disable freetyping in polyfilled fields yourself, because the library cannot support it.


Right now there are no plans to support this, for a few good reasons:

  1. If the user dirties the date field by typing manually, the library can no longer programmatically change its display value. This breaks the library.

  2. Native implementations (Chrome, iOS Safari) do not work this way. Chrome has keyboard input, but it isn't free-typing.

When I designed the polyfill behavior, I considered forcefully preventing free-typing input, but deemed this too invasive. Maybe it will prevent such input in the future, if this is revealed to be a common problem. Either way, it's pretty easy to add your own keydown handler that calls event.preventDefault().