ckeditor / ckeditor4-vue

Official CKEditor 4 Vue component
Other
75 stars 17 forks source link

CKEditor data not updated correctly if v-model changes during initialization timing window #139

Open wsiota opened 2 years ago

wsiota commented 2 years ago

Are you reporting a feature request or a bug?

Bug

Provide detailed reproduction steps (if any)

https://codesandbox.io/s/ckeditor4-vue-bug-report-v-model-timing-window-issue-s83ys2

  1. Use v-model with CKEditor4-Vue.
  2. Initialize this v-model to some value (the "initial value").
  3. Set the editor v-model to another value (the "new value") immediately after the instanceReady CKEditor event is emitted (or close to this timing window).

Expected result

CKEditor should show the updated model value ("new value").

Actual result

CKEditor shows the original model value ("initial value").

Other details

Additional Notes

  1. If the v-model "initial value" is set to an empty string and the "new value" is set during this timing window:
    • CKEditor will be empty
    • However, the v-model will contain the "new value." This means that Vue is still aware of what the editor value should be.
  2. If the v-model "initial value" is not an empty string and the "new value" is set during this timing window:
    • CKEditor will show the "initial value"
    • The v-model will not contain the "new value", as it is somehow overwritten (perhaps by an errant input event?). This means that the "new value" is lost!

We hit this by populating the CKEditor contents upon a page load from an async call (using v-model). It is not consistently reproducible in our app as it depends on hitting what seems to be a narrow timing window. But the provided CodeSandbox appears to consistently reproduce this by changing the v-model on the instanceReady event.

This could be related to #50.

github-actions[bot] commented 2 years ago

It's been a while since we last heard from you. We are marking this issue as stale due to inactivity. Please provide the requested feedback or the issue will be closed after next 7 days.

KarolDawidziuk commented 2 years ago

Hello, @wsiota, thanks for the report and I'm sorry for the late reply.

I see, that even giving a zero-latency timeout in the instanceReady() method for a model update solves the problem. 🤔

For now, I can confirm this issue.