-
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
Prioritize core blocks in the inserter #28945
Conversation
Size Change: +15 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
@@ -43,22 +43,14 @@ export function BlockTypesTab( { | |||
}, [ items ] ); | |||
|
|||
const itemsPerCategory = useMemo( () => { | |||
const getCategoryIndex = ( item ) => { |
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 seems to do nothing useful. I don't think I'm missing something here, but I'l like a sanity check :)
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 original intent for this was to sort the categories, though they might be sorted elsewhere now :)
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 picking this up! I wasn't sure if this behavior was intentional or not.
I could definitely see/agree with the argument that core blocks should be shown first. I do wonder if we want to give plugins the option to set the priority for whether their blocks appear before or after core blocks, but I think thats a separate discussion and follow up if necessary.
The changes here look good to me, although I'm not personally certain about the current usage of the getCategoryIndex
.
Anyways, thanks again!
14f778f
to
9f2ceb9
Compare
I agree that would be a separate discussion and follow up if necessary. Thanks for testing @Addison-Stavlo ! |
@Addison-Stavlo did you also test-run this? Just wondering if the PR can be merged. :-) Big thanks @ntsekouras for jumping in to fix this and also for adding tests! |
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.
@Addison-Stavlo did you also test-run this? Just wondering if the PR can be merged. :-)
Yup! I was just tentative to approve at first because I wasn't very sure about the category sorting removal, nor was I certain whether or not 3rd party blocks were intended to come first or not.
After more thought, some more testing, and seeing no objections - everything looks good and tests well from my end! 🚢
Description
3rd party blocks appear before core blocks in the sidebar inserter. This happens because third party blocks can be registered earlier than the core blocks (usually by using the
init
action), thus affecting the display order.This PR ensures core blocks are prioritized in the returned results.
Before
After
Related: Automattic/wp-calypso#46981
Checklist: