-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Issue with updated https://draftjs.org/ demo editor #2280
Comments
Oh huh, this is very odd. @yangshun updated the website— did you make any changes to the editor too? I wonder what's going on here, it didn't sound like any of this should change haha. |
I didn't make any changes to the editor, but now the editor is loading from npm instead of a hardcoded minified v0.11.3 version loaded via a script tag in Docusaurus 1. So this could be a regression in Draft.js rather than the website itself. I'll try to change to a different version of Draft.js in |
Upon further investigation, the editor works ok during local development but the generated site has a broken editor. I suspect it's due to the minification step. cc @endiliey for help! Anyway to turn off minification during the build step (other than hacking the local Docusaurus core in We need to try out the editor on a non-Docusaurus environment like CRA with minification to actually determine if it's Docusaurus' minification that's breaking it. Repro steps: Update: I set |
I think its a bad idea not to minify in prod. Bundle size will be very big. They can easily turn it off with configureWebpack hook (local plugin). Can you test it on CRA ? Minification is done by Terser (for JS). Our terser options is taken from CRA, so if it doesnt work on ours most likely it doesnt work on CRA. Unless the terser dependency has a bug, or CRA has updated their option |
My project has exactly the same issue as @yangshun presented on the gif. First weird behavior is that text selection and applying a block element (h1/h2/h3) always seems to apply it to the last line instead of the selected line, exactly like on the gif. Second weird behavior is that regardless of where you put the cursor, when you start to type, the characters appear somewhere on the last line. The first character that you type appears on the selected line, and then the selected line gets copied into the last line, and if you continue typing, those characters only appear on the last line. Attaching a gif: We do not use Docusaurus, we have an Elixir Phoenix web app, and it only uses React for this RTE, nothing else. We use webpack with babel-loader. The problem happens both in production and when running a dev server. So far we confirmed that this problem appears in
There is no problem on Chrome macOS Catalina and Chrome Linux. |
@angelikatyborska Is there a link to your project that we can access online? Try turning off the minification in the webpack build step and see if the problem goes away. |
Unfortunately it's a closed-source project of a company I work for, I can't share its code base. I'll try to create a fresh project to reproduce. The problem appears in our project in both development and production, so I doubt that it's caused by minificatiton. We use |
I spent more time going through our project's git history and I found the commit that introduced the bug. Long story short, our RTE broke when we added Cookiebot to our website. Adding this script to a page with an RTE creates the problems: <script id="Cookiebot"
src="https://consent.cookiebot.com/uc.js"
data-blockingmode="auto"
data-culture="en"
type="text/javascript">
</script> Of course I don't expect draft-js to be responsible for other random scripts ;). I'm just writing my finding in case there's somebody else with a similar problem. |
I see, so the bug in your app is not related to the minification process I guess. I wonder what cookiebot is doing that will break the RTE. |
Post |
Couple of notes:
|
From looking at the minified source I'm assuming it refers to this line, Which means we're failing to find the |
No, I experience no exceptions when I get this weird behavior from the gif from #2280 (comment) |
huh, maybe the exception is unrelated and it's a second bug? I'm on PTO until Janurary, so I'll have availability time to look into this, but thanks for letting me know @angelikatyborska |
My issue (#2280 (comment)) suddenly disappeared 🤷♀ I assume Cookiebot did a deployment that removed whatever caused the issue. I can't know what that was though because there's no changelogs, no npm packages, just the current minified live version of the script. |
@angelikatyborska I can get the broken behavior on Chrome as well sometimes... |
@yangshun I cloned the repo and ran the website without any changes and got no errors there. |
This PR will potentially fix this issue as well, but it was created to fix a separate issue, that happen to be on the same code path of the issue that is happening on the production website. |
By debugging the issue on the production site I can see that the editorState that we have access on |
I have recently encountered this issue and it seems it is definitely due to SSR as @fabiomcosta has pointed out. I had it occurring with a gatsby site only in production and managed to fix it using the workarounds in this issue: #2121 |
Disabled SSR-ing the editor in #2356 Checked the site just now and the editor isn't throwing on every keypress any more 👍 |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
The draftjs.org website was recently updated. The new demo editor on the site has a bug with pasting.
Steps to reproduce:
The paste will incorrectly be placed at the end of the "test", not at the cursor's location. The results will be "testtest" rather than "testestt".
The old demo editor behaved correctly and did not have this issue.
Running this on the latest version of Chrome.
The text was updated successfully, but these errors were encountered: