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] Uncaught TypeError: Cannot read property 'updateCurrentInput' of undefined #1503

Closed
alcarazzam opened this issue Jan 16, 2021 · 19 comments

Comments

@alcarazzam
Copy link

When I click on a block of any EditorJS instance when there are two editors in the same page, I get the following error:

Uncaught TypeError: Cannot read property 'updateCurrentInput' of undefined

This is where the error is produced:

public setCurrentBlockByChildNode(childNode: Node): Block {
/**
* If node is Text TextNode
*/
if (!$.isElement(childNode)) {
childNode = childNode.parentNode;
}
const parentFirstLevelBlock = (childNode as HTMLElement).closest(`.${Block.CSS.wrapper}`);
if (parentFirstLevelBlock) {
/**
* Update current Block's index
*
* @type {number}
*/
this.currentBlockIndex = this._blocks.nodes.indexOf(parentFirstLevelBlock as HTMLElement);
/**
* Update current block active input
*/
this.currentBlock.updateCurrentInput();
return this.currentBlock;
} else {
throw new Error('Can not find a Block from this child Node');
}
}

Steps to reproduce:

  1. Create two editors in the same page
  2. Click on a block

Expected behavior: No errors reported to the console.

Device, Browser, OS: Chromium 87

Editor.js version: 2.19.1

@alcarazzam alcarazzam added the bug label Jan 16, 2021
@samarjaffal
Copy link

Hi,
I have the same problem.
Currently using the editor on a Modal developed on React. When you open the modal again the error appears on the console.

@fatheyabdelslam
Copy link

i got the same thing

@davidyim
Copy link

I have the same problem, using Editor.js on React

@umutbozdag
Copy link

it's same for me too when i am using more than one editor instances in the same page

@aungmyohlaing
Copy link

I got the same. Using editor on modal with Vuejs

@pasloc
Copy link

pasloc commented Jan 20, 2021

I got the same error using the editor in nuxtjs. I have a toggle button which hides the editor. After toggling once the error occurs.

@stevenarrol
Copy link

Hey guys,
Had the same issue using React and was digging around for days trying to fix it. Figured out a way that seems to work.

Make sure you are initializing the editor using Class-based component, and then call editor.destroy() on unmount

componentWillUnmount() { this.editor.destroy() }

@pasloc
Copy link

pasloc commented Jan 21, 2021

this.editor.destroy() works for me too in Vue.js

@jbcl-io
Copy link

jbcl-io commented Jan 25, 2021

Seems editor.js does not support multiple editors in one page?

@hata6502
Copy link
Contributor

This bug occurs in the following demo page.
https://hata6502.github.io/editorjs-inline/

スクリーンショット 2021-01-25 19 57 37

Editor.js supported multiple instances in v.2.18.0.
But it seems broken in recently version.

@hata6502
Copy link
Contributor

https://github.com/codex-team/editor.js/pull/1364/files#diff-73cbc05ddd84b0686ee89460cb98dfc39099c8472677e743192f301e26c2347cR584

This error occurs in BlockManager.setCurrentBlockByChildNode()

I sent a pull request.

@singha-cto
Copy link

this.editor.destroy() works for me too in Vue.js

Please show exemple.

@susana-bit
Copy link

this.editor.destroy() works for me too in Vue.js

Same solution for Angular 10 and editorjs 2.19.1:

ngOnDestroy(): void {
    this.onDestroy$.next();
    this.editorInstance.destroy();
  }

@elbakerino
Copy link

Looks ok in 2.19.2-rc.1, doesn't crash anymore with multiple editors on same page.

But got a focus bug #1575, maybe related, thus tagging it here.

@laygir
Copy link

laygir commented Jul 8, 2021

Hello 👋

I am having this problem when switching from a regular input to EditorJS input by pressing tab key while there are multiple EditorJS instances present on the page.

Below is the demo page to reproduce the error. When the page loads first click on the input and then press tab then notice the error.

https://codesandbox.io/s/editorjs-cgsmq?file=/src/App.vue

@Haraldson
Copy link

Still seeing this with 2.22.2, using react-router-hash-link to scroll to header blocks in the editor. I guess it’s EditorJS is complaining about HashLink’s focus management, which is trying to give focus to the heading contenteditable.

@sifloz
Copy link

sifloz commented Dec 21, 2021

Hello, I'm trying to figure this out too. I'm currently working on an app that requires displaying more than one editor at the same time.

It all works perfectly until I start using editorjs plugins, such as the code plugin. When two or more editors are open and I start typing in them, this error is triggered.

Has anybody solved this?

Currently using it on a NextJS app at the 2.19.3 version (the latest one 2.22.2 also crashes).

@bytefulness
Copy link

I'm still having same issue my version is 2.26.4. Could you fix this issue?

@neSpecc
Copy link
Member

neSpecc commented Feb 20, 2023

I can't reproduce. Tried described steps along with CodeTool, no error.

Tried in 2.27.0-rc.1.

So'll close it for now. If a problem will occur, please, recreate an issue with more accurate steps to reproduce.

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

No branches or pull requests