withspectrum/draft-js-markdown-plugin

cursor loses position when typing any block level styles

watlandc opened this issue · 14 comments

Issue

When typing block level styles (ordered lists, headings, block quote, code block) the cursor immediately jumps to the line above the current position making block level styles unusable.

I'm experiencing the issue when using spectrum.chat, but the issue does not appear in the draft-js-markdown-plugin demo.

Browser and library version

Experienced the issue using an up-to-date version Chrome browser:

Version 65.0.3325.181 (Official Build) (64-bit)

It appears Spectrum uses version "draft-js-markdown-plugin": "1.3.0",

Demo

Video demo from spectrum.chat:

https://www.dropbox.com/s/ladtyfzru2qtz86/bullet%20point%20issue.mov?dl=0

Upon further testing, the cursor loses position when typing headings too.

wooot - @mxstbr is the latest version installed?

I can repro this on spectrum.chat in chrome btw, but not when I test the draft-js-markdown plugin in isolation

I updated the issue as requested, noting that Spectrum.chat is currently using:

"draft-js-markdown-plugin": "1.3.0"

oh that's unfortunate

Hmm might be one of our other plugins interfering?

@mxstbr this can be reproduced in a dev env I suppose?

I've started looking into this as well myself. This exists in my own project, but I haven't been able to reproduce it in the demo (yet). I won't be able to take a further look until Monday.

We upgraded to v1.4.0 and it's definitely still happening, ref withspectrum/spectrum#2779. We haven't updated anything else, so it must be some kind of mismatch?

This doesn't seem to be a plugin issue? I went in locally, removed all plugins except for the markdown plugin and it still happens for some reason. Trying to pinpoint the issue now!

This issue does not exist on Spectrum with v1.1.0 of the markdown plugin, but it does exist with v1.2.0 of the markdown plugin.

Here's the diff: 460a2d8...65e6779 Some change in there causes this broken behavior, but I'm not sure what it could be. @juliankrispel any clues?

Hmm, something seems to be generally broken—I'm also not seeing the new languages switcher, and exiting code blocks with ``` doesn't work either 😕

ok - I managed to repro it - by installing react-dom@16.2.0 😆 yep - banged my head against the wall for a few hours :/ - now I can actually debug the problem @mxstbr regarding the language switcher - I can totes see that in there when building alpha

Ok - I found the issue - the issue was as I suspected - corrupt SelectionState. It had always been there, but for some reason one of my updates must have exposed the bug - so here's the pr to fix it -> #47