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

[Bug] Problem with editor.destroy() in 2.19 #1380

Closed
neSpecc opened this issue Oct 15, 2020 · 4 comments · Fixed by #1404
Closed

[Bug] Problem with editor.destroy() in 2.19 #1380

neSpecc opened this issue Oct 15, 2020 · 4 comments · Fixed by #1404
Assignees

Comments

@neSpecc
Copy link
Member

neSpecc commented Oct 15, 2020

const editor = new EditorJS()

editor.destroy(); // TypeError: null is not an object (evaluating 'this.flipper.deactivate')

Steps to reproduce:

  1. Go to example/example.html
  2. Call editor.destroy() from the console
  3. You'll see TypeError: null is not an object (evaluating 'this.flipper.deactivate')

Expected behavior:

The editor destroys correctly.

Device, Browser, OS:

Safari

Editor.js version:

2.19

@sis-dk
Copy link
Contributor

sis-dk commented Oct 19, 2020

On editor destroy, we loop through moduleInstances and call destroy of each module.

Object.values(editor.moduleInstances)

moduleInstances contain both BlockSettings and Toolbar
https://github.com/codex-team/editor.js/blob/next/src/types-internal/editor-modules.d.ts

So when looping through the moduleInstances, we call BlockSettings destroy. Now as the loops continues, it reaches Toolbar and calls the destroy of it which agains attempts to destroy BlockSettings. This causes the editor to crash as BlockSettings was already destroyed. (Same with Toolbox)

private destroy(): void {

Is it ok to destroy an Editor level module from within another module? If yes, then should BlockSettings and Toolbox be contained within Toolbar and accessed only via Editor.Toolbar.BlockSettings?

@ilyapoz
Copy link

ilyapoz commented Nov 8, 2020

Do you plan to create a release with this bugfix?

@neSpecc
Copy link
Member Author

neSpecc commented Nov 9, 2020

Do you plan to create a release with this bugfix?

yes

@RajNandigalla
Copy link

waiting for the release @neSpecc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants