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

Updating an instance :config will fire its input event #29

Closed
pixelastic opened this issue Oct 12, 2017 · 2 comments
Closed

Updating an instance :config will fire its input event #29

pixelastic opened this issue Oct 12, 2017 · 2 comments
Labels

Comments

@pixelastic
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

  • Vue.js version : 2.4.2
  • Browser name and version : Chrome Version 60.0.3112.113 (Official Build) (64-bit) on Ubuntu
  • This package version : 4.0.0

Current behavior
I'm passing a :config object to my flat-pickr instance. Whenever I update that object (to update the minDate option for example), the @input event of the flat-pickr instance is fired.

Expected behavior
I would expect the @input to only fire when the actual value of the input change, not when it's config change.

Minimal reproduction of the problem with instructions
To give more context, I'm trying to build a form with two flat-pickr selectors. One for the "start date" and one for the "end date". I'd like to update the minDate option of the second instance to be the value of the first instance. In other words, I'd like to make sure it's not possible to pick an end date that is before the start date.

In the first instance @input, I'm changing the second instance config, but this also fires the second instance @input.

You can see the issue in action here: https://jsfiddle.net/2dLr1t1t/2/
Try to use the Foo date picker, and it will trigger the @input on the Bar datepicker as well. What is surprising is that it seems to only do it once (other updates of Foo won't update Bar).

@ankurk91
Copy link
Owner

ankurk91 commented Oct 12, 2017

You are updating config of second input when first input value gets changed . Each component watches for any change in config, apply them and tell date picker to redraw itself.

To ensure that everything is ok ; I also sets the current date. This is where input event gets emitted.
This is being discussed in issue #20 already.

Is there any harm input event gets emitted ?

@pixelastic
Copy link
Author

Thanks for the explanation, I understand why it behaves that way. A change in the config actually fires a change in the value itself.

From a user POV I find it surprising, but from a developer POV I see why it behaves that way. That being said, the event being called input, one could argue that is should only react to actual change to the input value, not its config.

As a workaround I'm checking the new value passed to the event. In the case of an update in the config, the value is actually empty and I can silently ignore the event. I can live with this workaround :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants