URLPopover: use new placement prop instead of legacy position prop#44391
URLPopover: use new placement prop instead of legacy position prop#44391
Conversation
|
Size Change: +134 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
26b5dd6 to
a679575
Compare
a679575 to
3c17672
Compare
tyxla
left a comment
There was a problem hiding this comment.
LGTM 👍
Just left a minor nitty question, other than that this is good to go 🚀
There was a problem hiding this comment.
Extreme nit, but with that order of logic, if someone passes both position and placement, the deprecated prop will take precedence. Should we do this only if placement is not specified?
There was a problem hiding this comment.
Since I moved the default value from position to placement, the placement prop can't really be undefined in the function's body. Therefore, in order to maintain backwards compat, I decided to implement the current logic.
I could refactor the logic and:
- move the default value assignment of
placementfrom the prop destructuring to later in the function body - make it so that when both
placementandpositionare defined,placementtakes the precedence
Let me know if this sounds like a good idea to you! If so, I'll go ahead and implement it
There was a problem hiding this comment.
What you suggested sounds good! I'll leave it to your judgment whether to implement it before merging.
There was a problem hiding this comment.
Pushed e149eef with those changes, let me know if it looks good to you!
9d012fc to
efd476f
Compare
efd476f to
e149eef
Compare
tyxla
left a comment
There was a problem hiding this comment.
Thanks for the extra comments. Looks great 🚀
What?
Part of #44401
Use the new
placementprop instead of the legacypositionprop to define thePopover's placement in theURLPopovercomponent.Why?
With the recent refactor of the
Popovercomponent tofloating-ui, we're in the process of refactoring all of its usages to the newplacementprop (native tofloating-ui). See #44401 for more detailsHow?
placementprop for theURLPopovercomponentpositionprop as deprecated — the prop, however, is still supported by the componentURLPopovercomponent uses the newplacementprop for thePopovercomponent, also thanks to thepositionToPlacementprop that is being exported from thePopovercomponentSee this conversion table that we're currently using to map
positionvalues toplacementvalues.Testing Instructions
trunkScreenshots or screencast
Kapture.2022-10-28.at.17.24.32.mp4
✍️ Dev Note
With the recent refactor of the
Popovercomponent to use thefloating-uilibrary, theplacementprop has become the recommended way to determine how the component positions with respect to its anchor. While the olderpositionprop is still supported, we're making changes towards removing all of its usages in the Gutenberg repository and deprecating it.As part of these efforts, the
positionprop has been marked as deprecated on the following components:Dropdownfrom the@wordpress/componentspackageURLPopovercomponent from the@wordpress/block-editorpackageConsumers of these components should be using the new
placementprop instead.