-
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
Make onPatternCategorySelection private #62130
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: +66 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
@ntsekouras, the difference is only the name change, correct? |
The name change and making the two components private. |
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.
Work as expected ✅
I just wish it was easier to add private props to components.
As an alternative to Symbols, you could create a uuid and use that as the prop name, and lock that. |
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.
This is great @ntsekouras - thank you for stepping in as time was of essence considering the approaching beta WP. Left some questions mostly from the experience in my previous PR.
@@ -341,4 +341,16 @@ function InserterMenu( | |||
); | |||
} | |||
|
|||
export default forwardRef( InserterMenu ); | |||
export const PrivateInserterMenu = forwardRef( InserterMenu ); |
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.
As far as I've seen the inserter menu component is:
- used exclusively in the block editor package
- used exclusively in the inserter component in the block editor package
- not specifically exported anywhere
What do we need the private component for?
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 thought about it too, and I think it would be fine to not create a private one. Sometimes though we can decide to make some existing components public (recent example here). With that in mind, it would be clear that some props are meant to remain private..
@@ -7,7 +7,7 @@ import { forwardRef } from '@wordpress/element'; | |||
/** | |||
* Internal dependencies | |||
*/ | |||
import InserterMenu from './menu'; | |||
import { PrivateInserterMenu } from './menu'; |
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 did you try to lock this? If you locked it and then used lock/unlock internally would it work for you? I may have stumbled on some lock / unlock bug in here but I am not sure if it's not some typo on my part.
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 it works, but there is no need to unlock if used in the same package.
return ( | ||
<PrivateInserterLibrary | ||
{ ...props } | ||
onPatternCategorySelection={ undefined } |
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.
this is reset to undefined
here but to const NOOP
in the private inserter menu, which makes the optional chaining maybe not needed.
One more reason to remove the private inserter menu component.
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.
Probably yes. I was just being defensive there.
@@ -3,8 +3,8 @@ | |||
*/ | |||
import { useDispatch, useSelect } from '@wordpress/data'; | |||
import { | |||
__experimentalLibrary as Library, |
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.
We kept the export right? So we export an __experimentalLibrary
which is less public than the locked one :) Should we stabilise the experimental export?
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.
Yeah, we could stabilize it and add a deprecation warning.
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]>
Co-authored-by: ntsekouras <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]>
What?
Follow up of: #60004 (comment)
Alternative of: #62110
This PR makes the newly added
__experimentalOnPatternCategorySelection
prop private and renames it toonPatternCategorySelection
Why?
We shouldn't add experimental features/props with just a prefix, because it will end up a public API in WP.
Testing Instructions