Problems with updating view.Selection and using view.Document#render #4186
Labels
package:engine
status:discussion
type:bug
This issue reports a buggy (incorrect) behavior.
type:improvement
This issue reports a possible enhancement of an existing feature.
From time to time we have a problem with
view.Selection
blowing up because of some unfortunate events.It happened last time, when view selection has not been updated and
view.Selection#editableElement
wasnull
when it wasn't expected. It made editor crash. Now we have another problem that I described in https://github.com/ckeditor/ckeditor5-upload/issues/55.I see two ways to go with this.
view.render()
. Ever. It is dangerous. You should accept that it is called onchangesDone
and if you want to re-render view, usemodel.Document#enqueueChanges
.model.DocumentSelection
change).First solution feels more like a hack than a solution. We know that rendering happens on
changesDone
so we useenqueueChanges
only to make sure that the view will be re-rendered. On the other hand, we could argue that we useenqueueChanges
to make sure that the view will be re-rendered at the appropriate moment. I could buy this. Another awkward thing is that we will need to usemodel.Document#enqueueChanges
to wrap things that are not connected with model at all, just like inImageUploadProgress
:In this case,
uploadedPercent
is a property of an object which is connected with upload mechanisms and it has nothing to do with model. The solution to the linked issue would look like this:However, once again, I could argue, that we should wait with any actions until all other changes that are processed are over. Hell, I could even argue that maybe
enqueueChanges
should not bemodel.Document
thing but acore.Editor
thing? Maybe it should be something that control execution flow not only in model but in the whole editor? 🤔Second solution at first glance looks more reasonable. The outdated
view.Selection
was the problem from the beginning, so let's fix the problem and let's not have an outdatedview.Selection
. I just wonder why we haven't done it at the first place? Maybe there were some bugs or conceptual problems that I don't remember? Or maybe we thought it will be more efficient and we don't have to updateview.Selection
that often?Discuss!
The text was updated successfully, but these errors were encountered: