Spacing-Visualizer: Handle undefined blockElement #69152
+6
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
Closes Automattic/jetpack#39417
When creating the
core/video
block transformed from another block, e.g.videopress/video
, theblockElement
could not be created yet, so it isundefined
. This code prevents an error, handing theundefined
scenario.Why?
There is an error when transforming from the VideoPress block to the video block and the error block is displayed with the message:
And the corresponding Javascript error in the console:
How?
The code returns the passed
state
in theuseReducer
when theblockElement
is undefined, keeping the previous state.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast
Before video
Kapture.2024-09-17.at.10.24.41.mp4
After video
CleanShot.2025-02-14.at.19.45.39.mp4