codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.4k stars 2.07k forks source link

[Bug] Cross-Focus between two EditorJS instances #1575

Open elbakerino opened 3 years ago

elbakerino commented 3 years ago

Describe a bug.

Multiple EditorJS instances on same page, each with own holder/different id.

When focusing the first one, then directly the second, the first ones toolmenu is still visible, only after a focus on not-editorjs closes both, with a focus in between it closes/opens correctly.

Expected behavior: Closing the menu of the first focused instance, when focusing directly into another EditorJS on the same page.

Screenshots: grafik

Device, Browser, OS: Desktop, Firefox 84, Windows 10

Editor.js version: 2.19.2-rc.1

Plugins you use with their versions: only paragraph, but inside react-editor-js@1.9.0

gabrielroman13 commented 4 months ago

Any update on the issue? Am am still facing this and on mobile is essentially troublesome.

(edit) A ghetto solving solution is to set the z-index of codex-editor class in reverse. Last instance must end with z-index: 1. Using this I made the following function that triggers on each instance of editorJs onReady():

function setEditorIndexes(){
        var editors = document.querySelectorAll('.codex-editor');

        var number = editors.length;

        editors.forEach((editor, index) => {
            editor.style.zIndex = number - index;
        }) ;
    }