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

fix: do not statically cache today's date #3004

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remolueoend
Copy link

Hey there, first of all thanks for developing and maintaining this library, it proved itself very useful!

I stumbled over the following issue a few days ago: Whenever a user kept my app open over multiple days, flatpickr's value for today is outdated. This affected all flatpickrs instances, even newly created ones.

Turns out that self.now of a flatpickr instance is initialized with the value stored in self.options.now. This value is statically initialized and won't be updated as long as the modules stay in memory. I guess that my issue is related to #1633, but redrawing does not help in this case.

I am not sure about the reasons behind caching options.now and propose to remove it altogether. What do you think?

Thanks a lot for looking into my PR,
remolueoend

@remolueoend remolueoend force-pushed the master branch 2 times, most recently from 4c62b7e to f5561e0 Compare April 5, 2024 16:41
`options.now` is not updated while flatpickr's script files stay in memory.
Because `self.now` is initialized with `options.now`, new instances of flatpickr
render an outdated date for today if the application itself is not reloaded over
multiple days.
@remolueoend
Copy link
Author

I just realized that defaultOptions can be overwritten by FlatpickrFn.defaultConfig. I therefore mark ParsedOptions.now as optional and do not initialize it statically. This still allows setting now explicitly via FlatpickrFn.defaultConfig.

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

Successfully merging this pull request may close these issues.

None yet

1 participant