globocom / megadraft

Megadraft is a Rich Text editor built on top of Facebook's Draft.JS featuring a nice default base of components and extensibility

Home Page:http://megadraft.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

blockComponent is recreated when special char is typed in the main editor

ShakurOo opened this issue · comments

-- Bug Report --

Expected Behavior

The blockComponent shouldn't be re-created all times

Current Behavior

Since the version 0.7.0 the blockComponent is always re-created when you write a special character like ê, ë (combinaison of two keyboard keys to being added).

Steps to Reproduce

Go to : https://codesandbox.io/s/megadraft-with-plugins-and-example-content-forked-ck83pb?file=/src/index.js

  1. Open the console, you see one ImageButton mount ... and ImageBlock mount ...
  2. Type something in the editor you, nothing happened in the console
  3. Now type character ê multiple times and see the console, the ImageBlock component is re-created for each character...
  4. Downgrade the version of megadraft under the 0.7.0, and type the special character, you can see the expected behavior

Browser, device, and OS

Screenshots

Capture d’écran 2022-09-15 à 19 11 28

Update: It seem's that the problem still comes with the version under 0.7.0. for this scenario :

  • Create a new empty block by pressing ENTER key (to create new paragraph)
  • Begins by typing the special char ê

You'll see again the ImageBlock re-mounting.

ImageBlock gets added as a plugin here:

for (let plugin of this.props.plugins || DEFAULT_PLUGINS) {
by default if you don't specify it as a plugin. What happens for you if you don't specify any plugins?

I also looked at the keybindings and couldn't find any default bindings that could cause this issue for you. I also couldn't replicate it myself

ALso, noticed opportunity for minor improvement on these components so opened a PR for them: #406