codex-team / editor.js

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

The whole inline-toolbar recreates itself endlessly when opening link-toolbar #2821

Open tmclagen opened 1 month ago

tmclagen commented 1 month ago

It's a very strange bug which becomes quite obvious and visible if you add a bit of transitions to the .ce-toolbar__content. For some reason if you open link-submenu the whole inline-toolbar gets recreated and repopulated endlessly until you click on an input element (make it focused). It doesn't happen on link creation because then the input gets focused initially, but when you try to edit a link, that's when the input doesn't get focused and the whole bug begins. At least, that's what I presumed at first but then I discovered that you can click anywhere inside the inline toolbar (not only input) and the vigorous recreation stops.

Steps to reproduce:

  1. Type some text
  2. Select some parts of it and turn it into a link
  3. Close the inline toolbar
  4. Double click on the created link to open the inline toolbar

Expected behavior:

  1. The inline toolbar elements should be created only once (at the init of editorjs or when you open the inline toolbar)
  2. It should work properly with transitions and animations to allow for open and close animations

You can see the bug in action here: https://github.com/user-attachments/assets/9c773f95-1f0f-4285-ad38-3c4a93dd8d3b

OS: Window 11 Browser: Google Chrome 128.0.6613.114 Editor.js version: 2.30.5

RobinDev commented 1 month ago

I patch this bug a dirty way by focusing the link input during renderActions :

setTimeout(() => this.nodes.input.focus(), 0)