-
Notifications
You must be signed in to change notification settings - Fork 4.7k
BlockPopover: Remove __unstableCoverTarget and __unstableRefreshSize in favour of BlockPopoverCover #59228
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
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +27 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
ramonjd
left a comment
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.
I like this change. More straight forward and comprehensible to use a component.
It's working as described in both post and site editors.
I can't see any regressions with the cover block or dropping files into the editor.
Tested in Firefox, Safari and Chrome, and Edge.
🍺
4e50848 to
82a8713
Compare
|
Flaky tests detected in 943c53f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7999221089
|
82a8713 to
943c53f
Compare
What, why, how?
Two improvements to how
BlockPopoverworks and its API.BlockPopoveris an internal component in@wordpress/block-editor. It's used extensively throughout the editor but not exported.1. Remove
__unstableCoverTargetfromBlockPopover.The
__unstableCoverTargetprop tellsBlockPopoverto position itself entirely over a block (width: 100%;height: 100%`). It's used for the empty block inserter, resize handles on the cover block, drop zone indicator, margin visualiser, padding visualiser, and so on.I've removed the
__unstableCoverTargetprop in favour of a newBlockPopoverCovercomponent that usesBlockPopoverinternally. Using composition instead of a prop makesBlockPopovermuch easier to reason about as it can be focused solely on positioning and not resizing.Old API:
New API:
2. Remove
__unstableRefreshSizeprop, and use aResizeObserverinstead.The
__unstableRefreshSizeprop works a bit likekeyand tells<BlockPopover __unstableCoverTarget>to update its size when the value of__unstableRefreshSizechanges.We can do away with it altogether by updating
BlockPopover(well,BlockPopoverCover, as above) to use aResizeObserverto automatically resize the cover when the block's size changes.As well as resulting in a much cleaner and less confusing API, this lets the cover resize automatically when the intrinsic size of the block changes e.g. when the user types content. We don't currently have a need to support this but will soon when I add
GridVisualizerin #59052.Testing Instructions
Test all the places that we were using
<BlockPopover __unstableCoverTarget>for regressions. No behaviour should have changed.trunk, see Fix MarginVisualizer and PaddingVisualizer #59227).