-
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
Fix editor crash when converting block with visible styles to reusable (after a save and page reload) #29059
Conversation
Size Change: +35 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
ad70bd4
to
a1cc4ac
Compare
Ok - I discovered that while my change fixed the problem I was trying to address, I'd made a mistake and introduced other bugs (thanks tests). I'll need to revisit this and find another way. |
This should be ready for review now, fixed by adding some extra guarding around the rendering of block styles. |
38fa982
to
33de4b0
Compare
33de4b0
to
9390e3c
Compare
yeah, that's the redux zombie bug, I thought we had it covered in useSelect (with the try/catch but maybe not in some cases) |
These things are very hard to debug, ideally the parent component should rerender first hide the whole inspector before the sub components and the "try catch" in useSelect is meant to actually catch these potential rerender issues when the child rerenders first. That said, I'm not sure I can provide more value, than an explanation of what's happening so I'm fine with the fix as is. It's a stop gap fix though and it can happen again if a new component is added there for instance. So the test is a very good addition. Thanks. |
Thanks for reviewing. I'll try to find out why the new test is failing. Hopefully it will just be a case of making it more robust. edit: the test needed to be updated for the new dialog that shows when creating a reusable block. |
This issue #29498 is also a zombie bug problem, I wonder if the current PR has an impact there. |
… prevent attempt to render non-existant block Refine dependencies Refactor a little bit more
9390e3c
to
2ffc493
Compare
It doesn't seem to affect #29498 (nav links don't have styles), but I also couldn't reproduce that one against the latest code in |
Description
Fixes #27243.
This issue happens when a block with block styles is converted to a reusable block. But it only seems to happen if a post with a block is saved, reloaded, and then the block is converted. Strange.
The issue seems to be that the Block Inspector is still rendering the converted block momentarily after it has been removed. This shouldn't happen, because the Block Inspector renders the selected block, and the block selection is updated as part of the process of converting to a reusable block. Most of the block inspector doesn't seem affected by rendering a removed block (seems like it's not being re-rendered), but the block styles do throw an error if the block doesn't exist, perhaps because they do their own
useSelect
call.In the process of fixing this I changed
BlockInspector
to usewithSelect
.How has this been tested?
I've added an end to end test, which fails on
master
.Manual steps
Expected: The block should be converted.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: