fabianmichael / kirby-markdown-field

Super-sophisticated markdown editor for Kirby 3, community built.
Other
160 stars 14 forks source link

Field loses content after change of URL appendix #164

Open medienbaecker opened 1 year ago

medienbaecker commented 1 year ago

A few months ago I noticed that the markdown field loses its content after you change the URL appendix of the page:

https://user-images.githubusercontent.com/7975568/213465849-b619c265-4afe-481f-abd0-40cb8685d57f.mp4

Now I finally had some time to have a closer look. Here's what I found:

It doesn't happen on slow connections

It doesn't happen when you throttle your connection speed to Fast 3G (1.5 Mb/s) or slower which leads me to the assumption that there's some kind of race happening while the content is transferred from the old page to the new page.

I can solve the issue by removing some code

When I remove the call to setValue() in this file the issue is solved. I do not fully understand what this line does, so I hesitated to create a PR. Nevertheless, I didn't notice any drawbacks after removing the watcher completely.

I was hoping you know what the line does so we can solve the issue. Thank you!

fabianmichael commented 1 year ago

@medienbaecker What Kirby-version are you using?

medienbaecker commented 1 year ago

I can reproduce it on every Kirby version, also on 3.9.0.

medienbaecker commented 1 year ago

@fabianmichael If I interpret your question correctly you could not reproduce it. Could it be related to hard drive speed? I have reproduced it on different servers, both local and remote.

fabianmichael commented 1 year ago

@medienbaecker Unfortunately, I did not have a chance of testing this so far but it really sounds like there’s some race condition involved. The issue probably appeared in an earlier version, there’s some leftovers of a skipNextChangeEvent variable, which is currently unsused. Maybe @sylvainjule knows something more about this issue from the time when the initial version of the plugin was developed?

philipmarnef commented 6 months ago

I'm seeing the same issue on 3.0.0-alpha.2 and Kirby 4.1.1...