Conversation
…division by zero error when it runs in componentDidMount
|
Size Change: +21 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Contributor
Contributor
|
Failing media modal related end-to-end tests are a known issue in Core and unrelated to this PR, see https://core.trac.wordpress.org/ticket/50025#comment:23. |
ockham
pushed a commit
that referenced
this pull request
Jan 27, 2021
…division by zero error when it runs in componentDidMount (#28499)
Contributor
|
Cherry-picked to |
|
If I now have a block cover with background image, fixed attachment and gradient overlay combined, the image disapears in the editor when I change alignment settings or reload the page (inline styles gone). Also when duplicating the block with ctrl + shift + D. Edit: Doesn't even need a gradient to reproduce. If I toggle the "attachment fixed" switch it's there again. |
Contributor
Author
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #28487. In #28096, because updateBounds was added to
componentDidMount, it runs after themediaRefexists, but before it has received the width/height or the image. This results in a division by 0 which errors out and sets the left bound of the focal point picker to beNaN. This caused the focal point picker to not work in the horizontal direction as well as throwing a console error.Specifically, these lines were erroring because dimensions.width and dimensions.height were both set to 0
How has this been tested?
Open a new post and insert a cover block
Select the cover block
See that the focal point picker can now be moved horizontally and there is no console error
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: