editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

[Bug] Uncaught TypeError: Cannot read property 'updateCurrentInput' of undefined

Open alcarazzam opened this issue 5 years ago • 21 comments

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:

https://github.com/codex-team/editor.js/blob/43032ebaac6a8b9a67c9bf2ada5adc0f8592d546/src/components/modules/blockManager.ts#L566-L593

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 avatar Jan 16 '21 12:01 alcarazzam

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.

samarjaffal avatar Jan 16 '21 14:01 samarjaffal

i got the same thing

fatheyabdelslam avatar Jan 17 '21 04:01 fatheyabdelslam

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

davidyim avatar Jan 19 '21 12:01 davidyim

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

umutbozdag avatar Jan 19 '21 12:01 umutbozdag

I got the same. Using editor on modal with Vuejs

aungmyohlaing avatar Jan 20 '21 09:01 aungmyohlaing

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.

pasloc avatar Jan 20 '21 14:01 pasloc

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() }

stevenarrol avatar Jan 21 '21 04:01 stevenarrol

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

pasloc avatar Jan 21 '21 06:01 pasloc

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

jbcl-io avatar Jan 25 '21 08:01 jbcl-io

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 avatar Jan 25 '21 10:01 hata6502

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

This error occurs in BlockManager.setCurrentBlockByChildNode()

I sent a pull request.

hata6502 avatar Jan 25 '21 12:01 hata6502

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

Please show exemple.

singha-cto avatar Jan 30 '21 07:01 singha-cto

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();
  }

susana-bit avatar Feb 18 '21 07:02 susana-bit

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.

elbakerino avatar Feb 28 '21 02:02 elbakerino

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

laygir avatar Jul 08 '21 20:07 laygir

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.

Haraldson avatar Oct 04 '21 14:10 Haraldson

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).

sifloz avatar Dec 21 '21 22:12 sifloz

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

bytefulness avatar Dec 19 '22 11:12 bytefulness

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.

neSpecc avatar Feb 20 '23 22:02 neSpecc

Hi team, still i faced same issue "Cannot read properties of undefined (reading 'updateCurrentInput')" can you help me

MathanChinnu avatar Jul 17 '24 10:07 MathanChinnu