wontlost-ltd/vaadin-litelement-ckeditor

VaadinCKEditor does not support Binder.hasChanges() correctly

Opened this issue · 0 comments

When binding VaadinCKEditor to a bean with a Vaadin Binder Binder.hasValue() shows an incorrect value after Binder.readBean().
With Binder.readBean() the VaadinCKEditor value will be resetted to the value from the bean.
As result of this Binder.hasChanges() should be false.
With VaadinCKEditor Binder.hasChanges() is true after readBean().

This is because VaadinCKEditor emits a value change event with fromClient=true after it has updated the UI on behalf of the server in JavaScript.
editor.editing.view.document.on( 'change:data') calls $server.setEditorData().
In Java setEditorData() calls setModelValue() with fromClient=true.
If Binder.readBean() had triggered the change:data, fromClient had to be false I guess.

Without a correct support of Binder.hasChanges() enabling/disabling save/undo buttons and checking changes, if the user tries to leave the page, is not possible.

I have written a little test app to demonstrate the problem: ckeditor-binder.zip