-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pasting text adds leading and trailing spaces #16172
Comments
This is happening to me to, every time, and makes editing a big hassle. Steps to reproduce listed above will always result in an extra space before and after the pasted text. This happens for any length of text within a block (words or complete sentences).
WP Version 5.2.2 |
I'm unable to reproduce this issue when checked out to the latest version of the editor in my development environment ( |
It doesn't seem to happen in a classic block, but it does in a paragraph block and list block, so please check those (there may be others). When I test copying and pasting between Classic and List blocks, the difference is in the pasting operation, not the copying, i.e. the contents of the clipboard are correct. In fact, I can confirm this using a clipboard application. |
@galbaras I didn't mean to sound dismissive of your original report, sorry if that's how it came across. WordPress 5.2.2 is running the equivalent I think of v5.3 of the Gutenberg plugin. The plugin itself though is now on v6.4 (and soon v6.5), so there have been lots of changes and bug fixes in the code base. I'm trying to establish whether it has been fixed in more recent versions. If you're able to test with the Gutenberg plugin installed and activated that would be useful. Here's a demo of my test: |
I didn't take your reply as dismissive. You'd need to replicate the problem in order to help. Your capture looks good, but... I've installed Gutenberg 6.4 and tested. The problem is still there. I can confirm that the scripts on the editor page were those of the plugin while I tested. If this is fixed in 6.5, I can test again. However, can you please take a look at the code for pasting text and compare Classic with, say, Paragraph? That may help isolate the problem. Sorry, I'm no good with React, so can't help :( |
Nope, not at all! :| I have just manually force-installed the development version of Gutenberg:
over production version of Gutenberg in my Wordpress 5.2.3. And either the development version was ignored / overloaded (after network activation of the plugin) by build-in production version of Gutenberg or the issue is still not fixed in Gutenberg 6.5.0. Anyway, I still see these two damn surrounding spaces around each pasted text. |
This bug is in effect in the current Gutenberg version (6.5). |
What do you mean by "in effect"? Is it fixed? Is it still not fixed in G6.5 or what? :> |
The bug made it to the production version. It is still there. Sorry, english is a second language for me... |
Thank you. Now, everything is clear! :> So, we're still waiting for the fix. No worries, we are all making mistakes. And that makes our lives really interesting. All the best to you. |
Sorry, to say this, but I find this feature extremely annoying. I am moving a lot of texts between many sources, so copy-paste is the key operation for me in Gutenberg. The fact that I have to stop and manually remove trailing and ending space with each and every paste influences performance of my work very negatively. This is an important bug (appears in many scenarios and affects most of, if not all of Gutenberg users). Yet it should be very small to fix -- an addition of training and ending space during is a very unusual, artificial operation, so narrowing the responsible piece of code shouldn't be a problem. Can we have any estimate when this will be fixed? |
@trejder Are you also on Windows? |
@ellatrix Yes! :> |
Am I the only one who has an even bigger problem with pasting? For me Gutenberg adds additional spaces completely randomly. Randomly meaning, while pasting the same text always at the same positions, but with (for me at least) no logical reason why exactly at those positions. I double checked and there are no double spaces in the source text. The exact same text pasted into the Classic element (within Gutenberg): No spaces. See here an example: PS: Sorry if this isn't helpful, first time posting here ;-) |
Since we're talking about editor that produces texts for website / blogs (where double spaces and all white characters are ignored) I think that the solution for problems all of us called up here would be a simple code that replaces all double spaces into single ones when pasting. |
I've seen that in pasts versions of Gutenberg. @michaelbruetsch What version are you using? |
@nicpelletier I'm using the current WordPress version 5.2.4. I read in this thread that WP uses a different version than the Gutenberg plugin itself here. So maybe that will be already fixed with the coming 5.3 update? Maybe I'm wrong in this thread. As I said, I'm new here ;-) |
I don't know how about @michaelbruetsch and pasting double spaces in random places. But, for the initial entry -- adding spaces in the beginning and end of each pasted text -- nothing changed so far. I have just updated to the newest stable / production version of Gutenberg 6.7.0 and still spaces are being added as you paste any text. |
Do we have any priorities for bugs and functionalities in Gutenberg development? Yesterday an update to Gutenberg inside Wordpress was released (version 6.7.0) and some breath-taking functionalities (sarcasm intended) like gradients in blocks were added. Yet, still no resolution on something as stupid (and in the same time affecting millions) as adding spaces when pasting text. Any estimate when can this bug be taken into consideration by the dev team? |
@trejder Please note that there's an etiquette guide - https://wordpress.org/about/etiquette/ - it specifically mentions unwelcoming behaviour. We're all smart enough here to understand what your sarcasm means, and it's not acceptable. Please be professional in future. I understand you desperately want to raise the profile of this bug and that it's important to you, but it's just as important that you're respectful to those who work hard and contribute to this project—after all, they're the ones who you want to encourage to help solve this. |
Thank you for pointing out that my behaviour and wording may not be acceptable by some. True apologies for those that felt offended. Yet, case remains unanswered. Are there any priorities, severity levels etc. or other ways or tools to rise awareness over a bug affected by most likely every user of Gutenberg and bring it closer to the resolution than some fancy new functionalities? Are there any ways to estimate, at least at highest level when and who can take over this particular issue? After all we are talking about a bug which resolution should take less than a half an hour (plus testing), because it only covers a tiny pasting functionality (my unconfirmed, possibly wrong assumptions). If any, be it internal or public, roadmaps, priorities etc. suggest that fix to this tiny, yet very painful bug is like months away in front of us (because team is occupied with adding new functionalities rather than fixing obvious bugs) then many of us will surely decide to give Gutenberg go. I don't imagine working with (otherwise perfect) editor which causes me to get a near-to-heartbreak state 300 times per hour, each time I am pasting some text. |
@michaelbruetsch Same problem here, WP 5.2.4 :-( |
The block editor is exciting to develop, and much less exciting to support, so thank you, @talldan , for taking the time and analysing. What would you suggest? By "which aren't removed by any of the filtering the editor does", I'm guessing you meant "currently". Is this a matter of adding some filtering before adding the text to the block? |
I think I have an idea on how to fix the second issue. It looks like stripping out the new lines that are outside of those The first one seems trickier, as there are potentially cases where newlines should be preserved in pasted text. @ellatrix might know more on how it works. |
Thank you @talldan for providing such a great review of this issue. However, there's one thing that I must correct (emphasis mine):
The above statement is not true, at least not in my environment (Chrome 78 + Windows 10 Pro), where this issue does exist and is observable by me with every text paste into Gutenberg. I have just performed a quick test of pasting text into Gutenberg editor from:
In all three cases the issue could be observed. All three pieces of text, even though carefully selected to not have any space in the beginning and in the end and though copied in the middle of the text, were pasted with spaces surrounding them. Before pasting: After pasting: |
Maybe too late, but just in case, this is for copying and pasting the word "become" in a paragraph block:
|
@galbaras That case should be fixed now and the fix will be in Gutenberg 7.2. |
Adding console dumps in step-by-step process of copying and pasting example piece of text from Visual Editor into Visual Editor. Step 1. Page / Visual Editor load on some draft article:
Step 2. Selecting and copying
Step 3. Pasting above copied text into some other place (new paragraph at the end of text) in Visual Editor. Getting
I maybe missing something, but it seems that console dump logs in both cases a text without any surrounding spaces in both Received HTML and Processed inline HTML. It only gets spaces added in Received plain text. Please, reopen the ticket. Reported issue is not solved in Gutenberg 7.0. Thank you. |
@ellatrix thank you. How can I test / check #19043 on my side? It doesn't seems to be included in Gutenberg 7.0 production. Shall I fetch dev code, overwrite production code with it and see, if the issue is resolved? And even, if yes, then what? Shall I revert back to production? Is there any plan, in which production version of Gutenberg #19043 will be released? |
@trejder One way I think you should be able to test without going through all those steps is using the block editor in the playground: This is a stripped-down version of the block editor which is missing some functionality, but the copy/paste handling should be the same as in the plugin and WordPress core. The playground is updated every time a pull request is merged, so it has all the latest fixes, including #19043. |
It will be in the next Gutenberg plugin version, 7.2.0 I think, and the next WP release, 5.4 I believe. |
So annoying. And still there mid Jan 2020, almost half a year since when the issue was raised. Any chances for a fix before the next ice age? |
Gutenberg 7.2 has fixed the issue: https://wordpress.org/plugins/gutenberg/ |
Seems true. I have just updated to Gutenberg 7.2 and it seems that I finally cannot reproduce this issue anymore. Thank you, t h a n k y o u, THANK YOU !!! |
Indeed it has, thank a million! My blogging life suddenly became slightly less annoying ;) |
In the current version 7.5, the old leading and trailing spaces problem doesn't appear. However, it seems to be solving it by merely trimming the pasted text. Doing so causes pasting spaces to be impossible. I would say this is still a buggy behavior. |
Agreed. But it's the lesser evil. In most cases I copy-paste stuff without leading/trailing spaces. |
On contrary to xpil, I disagree. If something is adding spaces (during copy) in front and in back of copied text (where original text does not include them) then solution by no means should be to stop that thing from adding these spaces rather than stripping spaces. This is up-side down solution, unfortunately. |
Again, I agree on the principle. It's better to fix a bug at source rather than blanketing it with an extra operation. No doubts here. But. For me as the end-user it's more important to use a feature that works correctly in 99% cases than to have a permanently broken one. End-users don't care about internals as long as they get the right outputs. |
With that clarification I can't do anything else than agree with you. I think that we may safely assume that there are approx. 90-95% of users not having spaces around copied text and only 5-10% intentionally coping text with spaces in the beginning or end. |
I agree that the current behavior is less bad than before, simply because adding spaces is easier than moving the cursor and removing them, not because it is a good solution. On the other hand, I can even argue for trimming the spaces: selecting a word by double-clicking also selects the trailing space which is usually unwanted and trimming removes it, which is good. But both behaviors break a fundamental user interaction principle: The software should do exactly what it is supposed to do. In this case, it is pasting exactly what the user has copied. For this kind of basic operation it is supposed to be 100% correct in all cases for 100% users. It took me quite a while to realize that it wasn't me who copied extra spaces around the sentences, but the software who was making them. |
The problem seems to be unrelated to the Gutenberg code. The browser is passing padded text to Gutenberg, by which time, the only course of action is either to remove them or to leave them. Also, if you look above, you'll see that I've checked the copied text in the Windows clipboard and it appeared to be correct. Removing is likely to provide better user experience than keeping the extra spaces. Not sure if this is any help, @talldan & @ellatrix , but looking back at our communication, I see that this only happens when pasting formatted text, not plain text, and there seems to be a clear difference between the Classic block and others. Can you confirm there's no other option here that will get us to 100%? |
@YukinoHayakawa I noticed this even happens when copying from one paragraph block and pasting into another. My feeling is that what's pasted should be as close as possible to what was copied. Would you be willing to open a new issue for this? |
I've opened #20310, would be great to add any further comments there. |
Appreciate your help in opening the new issue thread very much. I was hesitating about how to describe the problem in a good way. |
Following up here that this seems similar to the fix that when into #33607 in |
Describe the bug
When copying some text and then pasting it into a block, it is pasted with a space before and a space after with the normal Windows Paste operation.
When using PureText to paste a text-only version of the clipboard, no leading or trailing spaces are added.
To reproduce
Steps to reproduce the behavior:
Expected behavior
Exact copy of text pasted.
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: