-
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
List View: Fix crash when the first template-parts is deleted width del key #47227
Conversation
Size Change: +5 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in 9b8500f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3945545775
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guarding against null
here makes sense to me 👍
It would be nice to track down the actual cause of the issue, but I'm guessing it's related to Redux's "zombie children" or something similar.
Interestingly, the error doesn't happen if the first block is Reusable, which is also a synced
block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 thanks for digging in here and coming up with a fix! Optional chaining sounds good to me, for now 👍
@Mamaduka @andrewserong
Yes, this is very odd. However, I think this solution is reasonable for now and would like to merge 👍 |
Fixes: #47226
What?
This PR fixes the site editor crash when deleting the first template part block with the
del
key while the list view is open. This problem occurs when the template part block you are trying to delete is at the top of the block list.Why?
I have confirmed that the
useBlockDisplayInformation
hook returnsnull
when the first template part is deleted with the del key.I don't know why this does not occur when deleting from the dropdown, but I expect it is because the order of events and processing changes.
I also believe that the null check is necessary because
useBlockDisplayInformation
may returnnull
.How?
Added optional chaining.
Testing Instructions
Before
before.mp4
After
after.mp4