Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught CKEditorError: cannot-change-view-tree #12026

Closed
indraraj26 opened this issue Jul 7, 2022 · 10 comments · Fixed by #12074
Closed

Uncaught CKEditorError: cannot-change-view-tree #12026

indraraj26 opened this issue Jul 7, 2022 · 10 comments · Fixed by #12074
Assignees
Labels
package:engine package:font squad:core Issue to be handled by the Core team. support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior. type:regression This issue reports a bug that was not present in the previous releases.

Comments

@indraraj26
Copy link

indraraj26 commented Jul 7, 2022

📝 Provide detailed reproduction steps (if any)

Step 1: type something very fast and remove half word in the editor and instantly apply bold or switch to italic
Step 2: repeat step

I am using this package with Oracle Jet. self.connected and self.disconnected these are life cycles. It is throwing below error in a very rare case and after that editor becomes unresponsiveness and all the toolbar like bold, Italic will not work.

error:

Uncaught CKEditorError: cannot-change-view-tree
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-cannot-change-view-tree
    at Ra.change (ckeditor.js:6:455694)
    at Fc.listenTo.priority (ckeditor.js:6:521464)
    at $l.fire (ckeditor.js:6:318135)
    at $l._handleChangeBlock (ckeditor.js:6:587063)
    at vd._runPendingChanges (ckeditor.js:6:610822)
    at vd.change (ckeditor.js:6:607472)
    at Sp.execute (ckeditor.js:6:783299)
    at Sp.<anonymous> (ckeditor.js:6:327829)
    at Sp.fire (ckeditor.js:6:318135)
    at <computed> [as execute] (ckeditor.js:6:327881)

✔️ Expected result

It should not throw an error.

❌ Actual result

function MinHeightPlugin(editor) {
        this.editor = editor;
      }
      
MinHeightPlugin.prototype.init = function() {
const minHeight = this.editor.config.get('minHeight');
   this.editor.ui.view.editable.extendTemplate({
      attributes: {
            style: {
              minHeight
            }
     }
 });
};

const candidateEditorDataChanged = () => {
        const data = candidateEditor.getData();
        self.properties.noteToCandidate = data;
      }

// This is lifecycle which will emit when viewModel/Dom is ready
self.connected = () => {
        ClassicEditor.builtinPlugins.push(MinHeightPlugin);
        ClassicEditor
          .create( document.querySelector( '#editor1' ), {
            toolbar: [ 'heading', '|', 'bold', 'italic', '|', 'bulletedList', 
            'numberedList',  'blockQuote', '|', 'undo', 'redo',
            ],
            minHeight: '300px'
          }
             )
          .then((editor) => {
            candidateEditor = editor;
            editor.setData(self.properties.noteToCandidate)
            editor.model.document.on( 'change:data',  candidateEditorDataChanged);
          })
          .catch( error => { 
              console.error( error );
          } );
}

 self.disconnected = () => {
        candidateEditor.model.document.off('change:data', candidateEditorDataChanged);
 }

❓ Possible solution

If you have ideas, you can list them here. Otherwise, you can delete this section.

📃 Other details

  • Browser: Chrome Latest One
  • OS: Windows 11
  • First affected CKEditor version: "@ckeditor/ckeditor5-build-classic": "^34.2.0"
  • Installed CKEditor plugins:

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@indraraj26 indraraj26 added the type:bug This issue reports a buggy (incorrect) behavior. label Jul 7, 2022
@indraraj26
Copy link
Author

indraraj26 commented Jul 7, 2022

This is also reproducible in a sample.

Step 1: type something very fast and remove half word in the editor and instantly apply bold or switch to italic
Step 2: repeat step 1

image

@FilipTokarski
Copy link
Member

Hi, I'm not able to reproduce this. Could you add a screencast showing exactly what you do and when the error occurs?

@indraraj26
Copy link
Author

Hi Filip,

Here is the reproducible video.

record.mp4

Thank you

@indraraj26
Copy link
Author

Hi @FilipTokarski ,

Let me know if you still have any doubts, We can jump on a Zoom call.

Reproduce Steps:

Step 1: type something very fast and remove half word in the editor and instantly apply bold or switch to italic
Step 2: repeat step 1

Thank you

@FilipTokarski
Copy link
Member

Can you reproduce this also on docs demo or only in your customised editor?

@indraraj26
Copy link
Author

Hi @FilipTokarski ,

The cast or reproducible you see, It was of sample which comes with ckeditor package . Also it is reproducible on docs demo too.

Reproduce Steps:

Step 1: type something very fast and remove half word in the editor and instantly apply bold or switch to italic
Step 2: repeat step 1

image

@dufipl
Copy link
Contributor

dufipl commented Jul 13, 2022

Hello @indraraj26,
We were able to create simplified reproduction steps and reproduce the issue.

Steps

  1. Open this demo: https://ckeditor.com/docs/ckeditor5/34.2.0/examples/builds/document-editor.html
  2. Delete all contents and create a paragraph with e.g. "AAA" inside of it
  3. Put the cursor after the text
  4. Change the font
  5. Try to select the text

selection error

Therefore, we can confirm the issue.
Also, it is a regression introduced by version 34.2.0.
cc @Reinmar

@dufipl dufipl added squad:core Issue to be handled by the Core team. package:font type:regression This issue reports a bug that was not present in the previous releases. labels Jul 13, 2022
@FilipTokarski
Copy link
Member

Full stack trace:

Uncaught TypeError: Cannot read properties of null (reading 'parent')
    at Renderer.render (renderer.js:238:1)
    at View._render (view.js:702:1)
    at View.<anonymous> (view.js:204:1)
    at View.fire (emittermixin.js:200:1)
    at View.change (view.js:499:1)
    at View._disableRendering (view.js:689:1)
    at EditingController.listenTo.priority (editingcontroller.js:94:1)
    at Model.fire (emittermixin.js:200:1)
    at Model._runPendingChanges (model.js:961:1)
    at Model.change (model.js:202:1)

Uncaught CKEditorError: cannot-change-view-tree
Read more: https://ckeditor.com/docs/ckeditor5/latest/support/error-codes.html#error-cannot-change-view-tree
    at View.change (view.js:473:1)
    at View._disableRendering (view.js:689:1)
    at EditingController.listenTo.priority (editingcontroller.js:94:1)
    at Model.fire (emittermixin.js:200:1)
    at Model._runPendingChanges (model.js:961:1)
    at Model.change (model.js:202:1)
    at widgettypearound.js:358:1
    at FocusTracker.<anonymous> (widgettypearound.js:177:1)
    at FocusTracker.fire (emittermixin.js:200:1)
    at FocusTracker.set [as isFocused] (observablemixin.js:95:1)

@FilipTokarski
Copy link
Member

Bisection shows this commit: 22b97e9

@Reinmar
Copy link
Member

Reinmar commented Jul 14, 2022

Bisection shows this commit: 22b97e9

It was a fix for #11472.

@CKEditorBot CKEditorBot added the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Jul 15, 2022
@niegowski niegowski self-assigned this Jul 15, 2022
niegowski added a commit that referenced this issue Jul 18, 2022
Fix (engine): Editor should not crash while making a selection after having a collapsed selection with styles applied. Closes #12026.
@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Jul 18, 2022
@CKEditorBot CKEditorBot added this to the iteration 55 milestone Jul 18, 2022
@lslowikowska lslowikowska added the support:2 An issue reported by a commercially licensed client. label Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine package:font squad:core Issue to be handled by the Core team. support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior. type:regression This issue reports a bug that was not present in the previous releases.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants