Skip to content
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

New Splitting unification duplicates empty content blocks if a json attribute is present. #64071

Open
2 tasks done
albanyacademy opened this issue Jul 29, 2024 · 1 comment
Open
2 tasks done
Labels
[Type] Bug An existing feature does not function as intended

Comments

@albanyacademy
Copy link

Description

We have a content block which users were traditionally able to paste blocks into and it would replace itself with the pasted blocks, similar to how core/paragraph works.

Since 6.6, it not longer does only this. Now, the pasted block is sandwiched between the content blocks.

This appears to be due to the fact that these content blocks get some abstract attribute data set one way or another, and the splitting logic assumes that these blocks therefore are "splittable", when the only attribute it should be paying attention to with that regard is the content attribute (or whatever else we've named it).

I can also safely replicate this with the core/paragraph block (albeit through some code editor magic), so it's not isolated to our code.

This probably isn't that noticeable in core, maybe, but considering the fact that I'm able to replicate this with the core "metadata" attribute filled out might mean future complications.

I'm assuming this is caused by the split logic refactor #54543, though I can't pin down what specifically is the cause. I am worried that I can observe non-content attributes being duplicated implicitly, particular where unique attributes are concerned, such as anchors (obviously some stuff makes sense to include, but if there's no content to split...)

Step-by-step reproduction instructions

  1. create a new post, and enter the "code editor" view
  2. paste this:
    <!-- wp:paragraph {"metadata":{"someKey":"someValue"}} -->
    <p></p>
    <!-- /wp:paragraph -->
    
  3. then copy another block, preferably one that has no html markup (like the query block).
  4. ensuring the block is selected with the carat blinking, paste this other block.
  5. You should see the original core paragraph, the query block, and then another core paragraph in the block list.
  6. opening the code editor, note that the "metadata" attribute has been copied to the new block.

Screenshots, screen recording, code snippet

https://www.screencast.com/t/18Q4lW8vEJBN
https://www.screencast.com/t/irWnz897V

Environment info

wordpress 6.6

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
@albanyacademy albanyacademy added the [Type] Bug An existing feature does not function as intended label Jul 29, 2024
@ellatrix
Copy link
Member

I can also reproduce this when you have an aligned paragraph with no content, then paste something in it.

So there's two issues you're raising here I think?

  • metadata should not be copied.
  • If the content of the block is empty, replace it (even if there's other attributes set).

Or did you only mean to raise one? Did I misinterpret anything?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants