-
Notifications
You must be signed in to change notification settings - Fork 30
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
Input values are reset on going back/forward #25
Comments
Thanks for reporting this issue. I would need to go back into the Turbolinks Lifecycle and cache handling to properly understand what is going on. For now, as a fix I was able to get it to work by like this: import Flatpickr from "stimulus-flatpickr";
export default class extends Flatpickr {
change(selectedDates, dateStr) {
this.data.set('defaultDate', dateStr)
}
} at every date change, I update the default date I will need more test to see if I have to make it a default behavior or not of the wrapper. Let me know if this workaround is working too on your side |
actually, I made a few more tests and it looks like it works only for the second time, not the first time... |
For it to work from the start, I had to use <script src="bundle.js" data-turbolinks-track="reload" defer></script> and keep updating the data-attribute change(selectedDates, dateStr) {
this.data.set('defaultDate', dateStr)
} Here is a working demo https://glitch.com/edit/#!/dull-basil?path=src/controllers/datepicker_controller.js:5:2 |
Thanks for your answer. I have further tested with altInput false, but issue persisted. |
can you try to send me an example to reproduce exactly what you are doing and the issue Thanks |
Sorry, I typed previous message in a hurry on mobile. Your suggestion fixed my issue partially, because I use initialize() {
...
let value = this.element.value || this.element.querySelector('input').value;
if(!this.data.has('defaultDate') && value)
this.data.set('defaultDate', value);
} You can test it here https://glitch.com/edit/#!/heartbreaking-dust?path=src/controllers/datepicker_controller.js:6:4 |
The second example isn't working, but i have it working on my local environment. |
I have recreated small part of the wrapper and the issue came after the line disconnect() {
this.fp.destroy()
} https://glitch.com/edit/#!/probable-suede?path=src/controllers/datepicker_controller.js:11:21 Maybe we should save the |
Thanks for investigating this issue further. disconnect() {
const value = this.element.value
this.fp.destroy()
this.element.value = value
} live working example: I need to release a new version soon 1.1. I will add this patch to the official wrapper. This is something very linked to Turbolinks behavior. I am not sure Will close this issue with the associated PR and release for the fix Once again thanks for pointing it out |
Thank you for the good work. But you should probably use |
@adrienpoly I still see this issue in 3. I can reproduce 100% of the time by first doing pagination on a list (which uses turbo frames) and then click the back button. -- EDIT -- Some clarifying points:
|
The input values of flatpickr are reset to default value on first going back and on second return removed.
I have observed the issue on Safari, app with turbolinks and flatpickr with
altInput
.Expected behaviour
flatpickr should keep last typed value on returning back
P.S. I haven't tested the issue on other environment yet
The text was updated successfully, but these errors were encountered: