-
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
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
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.
LGTM 👍
Just left a minor nitty question, other than that this is good to go 🚀
alternative: '`placement` prop', | ||
} ); | ||
|
||
computedPlacement = positionToPlacement( position ); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
placement
from the prop destructuring to later in the function body - make it so that when both
placement
andposition
are defined,placement
takes 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed e149eef with those changes, let me know if it looks good to you!
9d012fc
to
efd476f
Compare
efd476f
to
e149eef
Compare
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.
Thanks for the extra comments. Looks great 🚀
What?
Part of #44401
Use the new
placement
prop instead of the legacyposition
prop to define thePopover
's placement in theURLPopover
component.Why?
With the recent refactor of the
Popover
component tofloating-ui
, we're in the process of refactoring all of its usages to the newplacement
prop (native tofloating-ui
). See #44401 for more detailsHow?
placement
prop for theURLPopover
componentposition
prop as deprecated — the prop, however, is still supported by the componentURLPopover
component uses the newplacement
prop for thePopover
component, also thanks to thepositionToPlacement
prop that is being exported from thePopover
componentSee this conversion table that we're currently using to map
position
values toplacement
values.Testing Instructions
trunk
Screenshots or screencast
Kapture.2022-10-28.at.17.24.32.mp4
✍️ Dev Note
With the recent refactor of the
Popover
component to use thefloating-ui
library, theplacement
prop has become the recommended way to determine how the component positions with respect to its anchor. While the olderposition
prop 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
position
prop has been marked as deprecated on the following components:Dropdown
from the@wordpress/components
packageURLPopover
component from the@wordpress/block-editor
packageConsumers of these components should be using the new
placement
prop instead.