WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.53k stars 4.21k forks source link

List item addition error #32590

Closed ginunn closed 3 years ago

ginunn commented 3 years ago

Description

I want to add an item to a list. I copy the item to the clipboard, go to the last list item, return to add a new item and paste. Nothing happens. If I enter one character from the keyboard and paste the paste then works. I delete the added character. Now I want to add a link to the added text item. If I select the text from left to right and add the link it is added to only part of the text line. If I select the text line from right to left, the link is added to the full text line. I can add the new list item to the top of the list without a problem. If I try to add the new list item into the list, same problem as adding to bottom. If I deactivate Gutenberg, close WP, reopen with the classic editor, the problem does not exist. Therefore it is a Gutenberg problem. I believe the problem first showed up about 2 weeks ago or so. ## Step-by-step reproduction instructions 1. Copy an external line of text such as a news item title to the clipboard. 2. Go to a WP page with a list of items and add to the bottom of the list as normal (return -> paste). Nothing happens. 3. Type an "x" as the new list item and paste. It works. Delete the "x" since you don't want it. 4. Go to the url of the page from which you copied the external item and copy to clipboard. 5. Select the list item you added by dragging left to right. Paste the link. It may cover only part of the selected text. 6. Repeat dragging right to left to select. It inserts the link properly. 7. Try inserting into the middle of the list - same problem. 8. Try adding to the top of the list. No problem!. 9. Deactivate Gutenberg and try inserting anywhere in the list with the classic editor. No problem. => It has to be Gutenberg. ## Expected behaviour Faultless addition to the bottom of a list. ## Actual behaviour Doesn't work without the workarounds described. ## Screenshots or screen recording (optional) none hekpful ## Code snippet (optional)

WordPress information

Device information

talldan commented 3 years ago

Here's the JavaScript error I saw when testing:

Uncaught TypeError: Cannot read property 'length' of undefined
    at addActiveFormats (index.js?ver=473d57b2e74938efee1fdbe05dcc46e5:31047)
    at HTMLUListElement._onPaste (index.js?ver=473d57b2e74938efee1fdbe05dcc46e5:30884)
glendaviesnz commented 3 years ago

Duplicate of #32526 & #32468 - immediate fix to the issue at #32527, but this either needs expanding to include a fix to prevent activeFormats from ending up undefined, or that could be handled in a follow up PR if we want to get a fix for the problem in quicker - this defensive fix doesn't appear to have any side effects.

talldan commented 3 years ago

Duplicate of #32468