Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-model changing from null to an empty string when popup is closed but nothing selected #224

Closed
lucianobosco opened this issue Apr 18, 2021 · 2 comments
Assignees

Comments

@lucianobosco
Copy link

I'm submitting a ... (check one with "x")

[ X] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

  • flatPickr version : ^4.6.6
  • Vue.js version : ~2.6.6
  • Browser name and version : Chrome Version 90.0.4430.72 (Official Build) (64-bit)
  • This package version : ~8.1.2

Current behavior
The v-model is changed from null to an empty string when popup is closed but nothing selected

Expected behavior
The v-model should remain as null

Minimal reproduction of the problem with instructions
1- Hydrate a vue-flatpikr v-model with null value
2- Focus the input
3- Blur the input and see how the property changes from null to ""

This behaviour gets some troubles with validation libraries such vee-validate, where a pristine flag is set to false if any field has changed its value.
The most common use case of this flag is to enable/disable submit button in a form, so when this scenario happens, the submit button becomes enabled despite no changes were made in regards to datepicker.

Not sure if this is related to an old bug I've reported to bootstrap-vue developers, but the same was happening with the <b-input> component which was fixed in PR 6084.

@lucianobosco
Copy link
Author

lucianobosco commented Apr 23, 2021

In addition, setting to null the v-model when the input already has a valid date is parsed as "" instead of null

In this sample there are 2 picker inputs, the first one always as null, showing the object type of value.
The second one has a valid date on mount, which changes its value to an empty string despite the button forces it to be null

https://jsfiddle.net/luchorengo/cL9dtvym/48/

@ankurk91 ankurk91 self-assigned this May 13, 2021
@ankurk91
Copy link
Owner

ankurk91 commented Jul 6, 2021

This has been fixed in v8.1.7 and v9.0.4

@ankurk91 ankurk91 closed this as completed Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants