-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Popover: lock the __experimentalPopoverPositionToPlacement function #47505
Conversation
Size Change: +24 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Marking as in need of dev note in case we establish that a prop rename is equivalent to a new prop |
I'm thinking that it might be better to avoid stabilizing this function. The cons are that It's a legacy function but will become a stable API indefinitely once released in WordPress core. It will have very limited use as everyone switches over to There seems to only be one use of the function outside of the components package, so other options could be either removing the export and duplicating the function or using the lock/unlock experiments API. |
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.
The cons are that It's a legacy function but will become a stable API indefinitely once released in WordPress core
This is a good point.
I don't have a strong preference towards either of the options @talldan suggested. Either would make it easier to remove the function in the longer term.
Other than that:
✅ Smoke test in editors didn't reveal any issues
✅ Unit tests pass & no typing errors
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 wonder if, in line with what @talldan and @aaronrobertshaw said, it makes sense to deprecate all APIs that are related to the old popover position prop, instead of stabilizing this API? In an ideal world where we're getting rid of deprecated APIs after some period, we'll be able to clean the legacy code up, instead of having it with us forever. Is there a good reason to want to keep maintaining the legacy API?
005ac79
to
35e8dc7
Compare
Thanks everyone for the feedback! I think that using Therefore, I went ahead and:
Feel free to give this PR a new round of reviews. I'll merge this PR only after #47229 gets merged. |
packages/components/CHANGELOG.md
Outdated
@@ -24,6 +24,7 @@ | |||
- `Button`: Convert to TypeScript ([#46997](https://github.com/WordPress/gutenberg/pull/46997)). | |||
- `QueryControls`: Convert to TypeScript ([#46721](https://github.com/WordPress/gutenberg/pull/46721)). | |||
- `Notice`: refactor to TypeScript ([47118](https://github.com/WordPress/gutenberg/pull/47118)). | |||
- Lock the `__experimentalPopoverPositionToPlacement` function and rename it to `popoverLegacyPositionToPlacement` ([#47505](https://github.com/WordPress/gutenberg/pull/47505)). |
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 think we ended up deciding in #47229 that it's nice to keep the __experimental
prefix so that can quickly identify which APIs are non-public.
Or maybe we could use a new __private
prefix for these cases?
I saw @youknowriad discussing these sorts of things in Slack. What do you think?
When the dust settles on 6.2 we should update backward-compatibility.md
with the best practices that we land on.
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.
Oh, but this is a function! not a prop. OK then I guess that's fine. Maybe. I don't know anymore 😭
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.
Added the __experimental
prefix for good measure (9f3158b). As you say, we can align naming conventions after 6.2 is released
Flaky tests detected in 4557ca7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4112506670
|
d1a795f
to
1709b42
Compare
9f3158b
to
0aebe0c
Compare
With #47229 merged, I rebased this PR to include the latest changes from This PR should be now ready for a final round of review |
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 iterating on this one @ciampo 👍
It's testing well for me.
✅ Project builds successfully
✅ Storybook examples work as expected
✅ URLPopover is positioned correctly and deprecation warning is output when using position
prop
✅ No remaining mentions of __experimentalPopoverPositionToPlacement
prop
LGTM! 🚢
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.
Nice work 👍
Needs a rebase, but the code looks great and it tests well.
🚀
0aebe0c
to
4557ca7
Compare
…47505) * Rename and stabilize __experimentalPopoverPositionToPlacement * Rename internal tests import statement * Revert "Rename internal tests import statement" This reverts commit 4a0602c. * Revert "Rename and stabilize __experimentalPopoverPositionToPlacement" This reverts commit 0d0a7aa. * Use lock/unlock APIs to lock the `positionToPlacement` function * Update CHANGELOG * Add __experimental prefix * Update CHANGELOG
Cherry-picked this PR to the wp/6.2 branch. |
What?
Part of #47196
Requires #47229 to be merged first
In an effort to reduce the amount of experimental APIs introduced to the repo, this PR uses the experimental
lock
/unlock
APIs to lock the__experimentalPopoverPositionToPlacement
function from the@wordpress/components
package, renaming it to__experimentalPopoverLegacyPositionToPlacement
.Why?
I had initially decided to stabilise this APIs, but following the conversations in this PR I later changed the approach and went for
lock
/unlock
. The whole point here is to prevent the__experimentalPopoverPositionToPlacement
from being released to core and therefore losing its "experimental" nature.Also, I decided not to introduce any soft deprecations and directly rename the export because it doesn't look like there any usages according to WPDirectory.
How?
@wordpress/components
, and instead added the function under theexperiments
object (which is locked)URLPopover
) to use theunlock
APIs to retrieve the same functionTesting Instructions
Popover
Storybook example work as expectedURLPopover
is positioned correctly in the editor (as ontrunk
)__experimentalPopoverPositionToPlacement
propDetailed instructions on how to test the `URLPopover` component
position
prop, which should trigger the unlocked functionURLPopover
renders on top of the block toolbar, and that a warning is printed to the browser's console (sinceposition
is deprecated)