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

Block transformation is not working due to canInsertBlockType is returning false. #46740

Open
dipeshkakadiya opened this issue Dec 22, 2022 · 3 comments
Labels
[Feature] Blocks Overall functionality of blocks [Type] Regression Related to a regression in the latest release

Comments

@dipeshkakadiya
Copy link

dipeshkakadiya commented Dec 22, 2022

Description

I'm trying to do custom code so I can transform one block to another block automatically on post load.

In my case, I enabled core/legacy-widget for post editor and auto transformation will find here.

https://gist.github.com/dipeshkakadiya/6f18792be4d7c170eb6c71cc63e4d713

On replaceBlocks, canInsertBlockType is returning false. If I'm trying to manually transformation then canInsertBlockType return Ture.

Above issue occure with WordPress version 6.1. With WordPress 6.0 it was working fine.

Step-by-step reproduction instructions

Use blow script to transform one block to another block.

https://gist.github.com/dipeshkakadiya/6f18792be4d7c170eb6c71cc63e4d713

Screenshots, screen recording, code snippet

Auto Transformation on Page load

Screenshot 2022-12-22 at 5 43 11 PM

Manual Transformation

Screenshot 2022-12-22 at 5 43 46 PM

Environment info

WordPress Version : 6.1
browser : Chrome

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

@dipeshkakadiya
Copy link
Author

dipeshkakadiya commented Dec 22, 2022

While debugging I found out in canInsertBlockTypeUnmemoized method state is different in both case.

Screenshot 2022-12-22 at 5 54 36 PM

Screenshot 2022-12-22 at 5 54 44 PM

Look like auto transformation might be too soon. Please share any suggestion to fix this issue. More weird part is this custom functionality was working on WordPress 6.0 version. Something changed in WordPress 6.1 effecting this.

@tyxla
Copy link
Member

tyxla commented Dec 22, 2022

Haven't been able to dig further, but this looks like this could be related to the recent perf optimizations we did in #46146 and #46204, cc @youknowriad

@kathrynwp kathrynwp added [Type] Regression Related to a regression in the latest release [Feature] Blocks Overall functionality of blocks labels Dec 22, 2022
@youknowriad
Copy link
Contributor

I think this is unrelated to these refactorings since these are not present on WP 6.1 AFAIK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

4 participants