-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Heading unexpectedly loses formatting when copy and pasting #48040
Comments
Came here to report this as well. |
With formatting, you mean the heading element? Could you share what's logged in the console? I'm trying this in Chrome and what the browser is giving us in the clipboard is text without the heading, so we just look at that. Is this a regression? Did it not always behave like this? |
@ellatrix Yes.
CleanShot.2023-02-20.at.04.39.39.mp4
Yes, it's a regression. Interestingly, 'Copy block' seems to work fine: CleanShot.2023-02-20.at.04.43.23.mp4Maybe something changed about what the browser sees as selected? |
@danielbachhuber I was just testing this in WordPress 6.1.1 without Gutenberg, and the behavior appears to be the same. So while I agree that this is not the ideal behavior, I am not sure it's actually a regression. Would you be able to confirm on your end? I'm just trying to whittle down the "Todos" for 6.2 as we prep for Beta 3, so if this is not a regression between 6.1 and 6.2, I recommend we punt to 6.3. Thanks! |
@ndiego I can confirm the same error occurs in WordPress 6.1.1.
Regardless of the semantics, it seems like a pretty glaring bug to leave unfixed for a full cycle. |
100% agree, it would be great to get it fixed in time. I'm just concerned with the amount of other issues currently on the board. It does appear that this issue has existed at least as far back as 5.9. cc @annezazu |
@ndiego It stopped working more recently than 5.9, so maybe it's a change in browser behavior? |
Noting that I can replicate this with 6.3 beta 4. For further sleuthing, I noticed if I use the three dot menu > copy, it works. But if I select and copy, it doesn't: heading.dependent.mov |
A user is reporting the same thing. They used to edit the post in Words and then paste the content into the Post Editor, and the formatting translated well. Based on their report, it stopped working. After pasting the text loses all previous formatting. |
Copy and pasting from other applications into the Editor should still work in most cases, so long as the copied text was actually a heading. If not @csabarakasz would you be able to report an issue? This issue refers to copying a Heading within the Editor and then the formatting is lost. Given that this is not a new issue in 6.3, I recommend we punt unless anyone thinks we will be able to get a PR put together in time. Based on the discussion in the PR, which has already been punted, it seems quite tricky, but I defer to @ellatrix |
This issue is already present in 6.2 and we're in RC phase for 6.3 so let's leave it out for now. |
In my Windows environment, Firefox does not seem to have solved this problem. If I copy all the text in a heading block and paste it into an empty paragraph, the text appears to have been copied correctly, but the block remains a paragraph block. It also appears that the heading element is nested in the block itself. Could you please re-test this issue to see if it works correctly in all browsers on MacOS? Also, #48254 seems to have created a new problem with #53422. 8b8a73ca4869937a33d78e572950aed5.mp4 |
On macOS, I tested in Chrome, Safari, Orion and Firefox and in each the behavior works as intended by #48254. A heading is inserted to replace to the empty paragraph. However, I'm not sure this feels entirely right or of much value. If I copy/cut just a portion of a headline and paste it into a non-empty paragraph then it splits and I get a headline after the paragraph. It’s not a heavy lift to merge blocks after that (or avoid the split by pasting with cmd+shift+V) but the behavior doesn’t seem correct in such instances. As for its value in general—if I want a duplicate headline—I duplicate the block and I wouldn't miss this feature. If this really is a regression and must be fixed, it seems it would be worth tracking down how it broke and how it worked before. For now, given the issue Aki raised, I'd lean toward reverting #48254. |
Personally, I find it strange that when I paste copied text, the formatting (in this case, the heading element) is also pasted. I expect that when text is copied, only the selected text and the inline formatting within it will be copied. Therefore, when I copy the entire text of a heading block and paste it into an empty paragraph, the expected behavior for me is that it will remain a paragraph and not be converted to a heading. If you want to copy the block itself, you can press |
From a writing UX perspective, inline formatting and heading levels should be treated the same. The idea that these are separate "blocks" doesn't need to be expressed technically. If you copy a heading and paste it somewhere else — it should remain a heading. If I copy a heading and paste it within a paragraph block that has content already, then I'd expect it to be added to the content as paragraph text within that block. This is how Google docs works for example. It even goes one step further, maintaining the heading font size when you paste into a paragraph (but I don't feel that's necessary).
Copying should work the same, however it's copied (again, from the writing UX perspective). |
For me, Firefox seems to behave fine. I'm not seeing the nested heading in a paragraph issue. I do agree that we need some more fine tuning here. For example:
Would you agree? |
Btw, I've added support for Firefox e2e test for paste in #53482. |
I just tested each minor from 6.0 to 5.3 and none of them copy/paste the Heading as formatting. This doesn't appear to be a regression and thus changing it is an "enhancement". Side note: it’s awesome how quickly wp-now allows testing those but I ran into failures with <5.3. There is probably an agreeable compromise that can be made here, though in my view, the way it was before doesn't need changing. It's easier to copy the whole block with two existing methods than to select its whole content to do so.
I think the state of the selection when copied is the key thing to consider. If the selection is the whole content of the block, that’s okay to treat as "copy the block". If the content is partially selected then treat it as "copy the content". Doing that means pasting should take care of itself, right? |
Yes.
Yes, that's what this issue covers: #53076 |
Okay, I have summarized how it behaves in MS-Word and Google Docs. MS-Word
Google Docs
Given these factors, what would be the ideal behavior? |
Moving this out of the 6.4 board as we're in the beta cycle and only bugs related to this release can be addressed at this stage. |
There is a PR attached to this issue
@danielbachhuber does this fix the issue? If yes, we could probably close this issue as completed... |
It was reverted |
Punting this as no work has been done and we're closing in on crunch time for beta 1 for 6.5. |
Hi folks, |
Description
When I copy and paste a heading, the heading loses its formatting:
CleanShot.2023-02-13.at.09.29.20.mp4
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: