Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#13462 closed Bug (invalid)

Calling getSelected On Widget Marks Editor As Dirty

Reported by: bmulholland Owned by:
Priority: Normal Milestone:
Component: UI : Widgets Version:
Keywords: Cc:

Description

This is very similar to https://dev.ckeditor.com/ticket/11753 except instead of clicking on the widget, call getSelected(true) on a widget.

We use this for an integration: There's a list of widgets outside of the editor, and you can click on the list to select and scroll to the widget in question.

Repro:

1) Open the widget demo page http://ckeditor.com/demo#widgets

2) Run the following in your console: console.log(CKEDITOR.instances.editor1.checkDirty()); CKEDITOR.instances.editor1.widgets.instances["0"].setSelected(true); console.log(CKEDITOR.instances.editor1.checkDirty());

Expected: Console outputs false twice, because the editor remains not-dirty.

Actual: Console outputs false then true, because setSelected marks it as dirty.

Change History (4)

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

Keywords: dirty widgets removed
Resolution: invalid
Status: newclosed
Version: 4.4.7

If you call widget.setSelected() then you need to take care of the dirty flag just like here - https://github.com/ckeditor/ckeditor-dev/blob/8b70a2318268fd71609e60c1e207237e33ee800c/plugins/widget/plugin.js#L1205-L1209. In other words - setSelected() is a low-level method.

Another thing is that using checkDirty() with widgets is not the safest choice. This method exists since the very beginning, but it stopped being feasible to fully support it with all the new features that were created. I rather recommend comparing editor.getData(), but not too often since this method is much heavier than editor.getSnapshot() which is used by checkDirty().

comment:2 Changed 9 years ago by bmulholland

Thanks Reinmar. Perhaps this could be flagged in the docs? Happy to make a PR for that. Do you have a preference about how and where to make that note?

comment:3 Changed 9 years ago by Piotrek Koszuliński

As I was on it already I fixed it - https://github.com/ckeditor/ckeditor-dev/commit/b1ffae60986aed23613e646c5e5f7c304e29838f. The methods should actually be private from the beginning... but let's keep them this way.

comment:4 Changed 9 years ago by bmulholland

That's great! Thanks Reinmar :)

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