Opened 10 years ago

Last modified 10 years ago

#11753 closed Bug

CheckDirty is true after clicking a widget, but getData() returns the same — at Version 5

Reported by: Joel Owned by: Artur Delura
Priority: Normal Milestone: CKEditor 4.4.2
Component: General Version: 4.3
Keywords: Cc:

Description (last modified by Artur Delura)

In Chrome33 and IE9, the checkDirty() method returns true after a widget drag handle has appeared, even though nothing has changed.

  1. Open Developers console
  2. Go to http://ckeditor.com/demo#widgets
  3. Run CKEDITOR.instances.editor3.checkDirty(); in console

--> returns false

  1. Run var d1 = CKEDITOR.instances.editor3.getData(); in console
  2. Click on the apollo picture in the 2nd editor, but do not move it.
  3. Run CKEDITOR.instances.editor3.checkDirty(); in console

--> returns true

  1. Run var d2 = CKEDITOR.instances.editor3.getData(); in console
  2. run d1 === d2 in console

--> returns true

I know this is a battle between getData() vs getSnapshot() vs _.previousValue, but as far as I can see, it is unexpected behaviour. Shouldn't checkDirty() work with getData() especially when there are widgets involved?

Switching to source mode and back does not help.


Bonus: In Chrome CKEDITOR.instances.editor4.checkDirty(); is always true after page has loaded.

Change History (5)

comment:1 Changed 10 years ago by Piotrek Koszuliński

Status: newconfirmed
Version: 4.3

There's no integration between widgets and checkDirty at all. Honestly speaking, we've got a problem with checkDirty, because whatever we do with DOM it yields. And with widgets we do a lot.

So either we'll reimplement it (only possible with undo manager...), or every single time DOM we change something irrelevant in the DOM we need to reset checkDirty to correct state.

comment:2 Changed 10 years ago by Artur Delura

Owner: set to Artur Delura
Status: confirmedassigned

comment:3 Changed 10 years ago by Jakub Ś

or every single time DOM we change something irrelevant in the DOM we need to reset checkDirty to correct state

What if some other part of code e.g. custom plugin changes dirty state at the same time (and relies on it)? If such thing happens then, not only it breaks custom plugin but also our onchange is becoming more and more useless.

comment:4 Changed 10 years ago by Piotrek Koszuliński

Other plugins should not rely on the dirty flag. It is only for integration purposes. Other plugins should only take care of not changing it when it shouldn't be changed. Just like in this case - the flag should not be change to true when widget is focused or blurred.

Last edited 10 years ago by Piotrek Koszuliński (previous) (diff)

comment:5 Changed 10 years ago by Artur Delura

Description: modified (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy