Opened 10 years ago
Closed 10 years ago
#12300 closed Bug (fixed)
Editor#change fired on first navigation key press after typing
Reported by: | Piotrek Koszuliński | Owned by: | Artur Delura |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.4.6 |
Component: | General | Version: | 4.4.4 |
Keywords: | Cc: |
Change History (13)
comment:1 Changed 10 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 10 years ago by
Owner: | set to Artur Delura |
---|---|
Status: | confirmed → assigned |
comment:3 Changed 10 years ago by
Status: | assigned → review |
---|
comment:4 Changed 10 years ago by
Status: | review → review_failed |
---|
I don't like this solution :). I don't know the code well enough to give details, but my gut says that this is a wrong place making it a hack instead of real solution.
As I can see undo manager knows pretty much nothing about editing handler - so far it used it in only one place - https://github.com/ckeditor/ckeditor-dev/blob/master/plugins/undo/plugin.js#L293 - which is already too much and I didn't like this either. But let's say that undoManager#type
should be moved to editingHandler
class because it does its job, so it's ok, because after the change undoManager would know nothing about it again.
What you did is made the undoManager#save
method dependent on editingHandler
and that's worse, because the save()
method is totally generic - it's not and should not be related to typing, hence it should not access editingHandler
.
What I would suggest is that this case should be handled before save()
is called - most likely it should not be called at all.
comment:5 Changed 10 years ago by
Let's close #12354, masterize and then rebase branch for this ticket to new master, before we make some further changes in this ticket branch. Now we both have wider view about undo manager, so I can find out better solution I guess :)
comment:6 Changed 10 years ago by
Milestone: | CKEditor 4.4.5 → CKEditor 4.4.6 |
---|
comment:7 Changed 10 years ago by
Status: | review_failed → review |
---|
I used the editing handler
to get the lastKeydownImage
which is by the way passed as a second argument in the save
function. I moved out call to the editing handler to the onKeydown
method in the nativeEditingHandler
. But I don't see this as a good solution (I preffer the previous one). Anyway, changes in branch:t/12300.
comment:8 follow-up: 10 Changed 10 years ago by
- I don't like and see a need for the change in equalsContent. It's not tested, not documented and finally I don't see that we are starting using this method without passing an argument there. What's more, you should check whether some image exists before calling equalsContent.
- I don't think that one test is enough for this change. For example I changed the line to:
undoManager.save( false, this.lastKeydownImage, false );
And all the tests passed. So either my change is correct, or the tests are not sufficient.
comment:9 Changed 10 years ago by
Status: | review → review_failed |
---|
comment:10 Changed 10 years ago by
Replying to Reinmar:
- I don't like and see a need for the change in equalsContent. It's not tested, not documented and finally I don't see that we are starting using this method without passing an argument there.
But what is wrong with it? This additional check won't break nothing.
What's more, you should check whether some image exists before calling equalsContent.
Why overcomplicate things and why it's important? When we call equalsContent
we don't need to check anymore whether passed argument exists.
comment:11 Changed 10 years ago by
The change must have a reason. In this case the doc says that the otherImage is a required argument and I don't see any place where we stop passing the otherImage. So starting checking if it's passed, without changing the docs and without a reason is totally wrong.
Moreover, it's also wrong because the existence of other image should be checked outside the method, in the code that uses it. The reason for that are silent errors that may be caused by such checks inside the method and confusion which such checks create when they are placed inside (if that's not backed up by the docs).
Furthermore, if the argument isn't passed the code should throw an error, not return false...
tl;dr Changing this without a reason is the overcomplication.
comment:12 Changed 10 years ago by
Status: | review_failed → review |
---|
We decided that checking whether current editor snapshot is same as lastKeydownImage is not necessary because it's always true
. Changes in branch:t/12300.
comment:13 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | review → closed |
Fixed on master with git:184dc7f.
Changes and tests in branch:t/12300. I'm not sure whether we should apply same checking in diffrent places. Search for this:
.equalsContent(