-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new API to allow inserter items to be prioritised (#50510)
* Proposing a way to sort items in the block inspector based on allowed blocks * Add inserterPriority API to inner blocks * Sort inserter based on inserterPriority prop from block list settings * Use new inserterPriority API in Nav block * Correct comment Co-authored-by: Andrei Draganescu <[email protected]> * Remove redundant prop * Avoid stale inserterPriority * Make sorting function stable * Renaming * Remove redundant comment * remove spacer * Set prioritisedBlocks as empty array when no blockListSettings are found. There are instances in the main inserter search results where the rootClientId is undefined, such as when searching for a block. This means there are no blockListSettings, which ends up in no `proritisedBlocks` property being returned and it crashses the app. * proritise -> prioritize for consistency * Update packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js Co-authored-by: Alex Lende <[email protected]> * Renaming constant to match updated name * Add prioritizedKInnerBlocks to the inner-blocks README * lint fix * update comment * update comment * pass the correct props to useNestedSettingsUpdate * Use stable ref Co-authored-by: George Mamadashvili <[email protected]> * Register the test Plugin for e2e tests * Register block with prioritzedInserterBlocks set * Add initial test scaffold * Tidy up scaffolded test * Add test for new API It fails :( * Try removing sort from helper Why is this even here? It shouldn’t transfer results like this. * Fix test * Add test to check does not override allowedBlocks when conflicted * Add additional assertion for retaining of correct number of results * Ensure tests reflect target of Quick Inserter * sort allowed blocks on the tests that consume getAllBlockInserterItemTitles * Improve e2e test comment * Update packages/block-editor/src/components/inner-blocks/use-nested-settings-update.js * Update packages/block-editor/src/components/inner-blocks/README.md --------- Co-authored-by: Dave Smith <[email protected]> Co-authored-by: Andrei Draganescu <[email protected]> Co-authored-by: Jerry Jones <[email protected]> Co-authored-by: Alex Lende <[email protected]> Co-authored-by: George Mamadashvili <[email protected]> Co-authored-by: MaggieCabrera <[email protected]>
- Loading branch information
1 parent
541b0dd
commit adefb89
Showing
16 changed files
with
328 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/e2e-tests/plugins/inner-blocks-prioritized-inserter-blocks.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* Plugin Name: Gutenberg Test InnerBlocks Prioritized Inserter Blocks | ||
* Plugin URI: https://github.com/WordPress/gutenberg | ||
* Author: Gutenberg Team | ||
* | ||
* @package gutenberg-test-inner-blocks-prioritized-inserter-blocks | ||
*/ | ||
|
||
/** | ||
* Registers a custom script for the plugin. | ||
*/ | ||
function enqueue_inner_blocks_prioritized_inserter_blocks_script() { | ||
wp_enqueue_script( | ||
'gutenberg-test-inner-blocks-prioritized-inserter-blocks', | ||
plugins_url( 'inner-blocks-prioritized-inserter-blocks/index.js', __FILE__ ), | ||
array( | ||
'wp-blocks', | ||
'wp-block-editor', | ||
'wp-element', | ||
'wp-i18n', | ||
), | ||
filemtime( plugin_dir_path( __FILE__ ) . 'inner-blocks-prioritized-inserter-blocks/index.js' ), | ||
true | ||
); | ||
} | ||
|
||
add_action( 'init', 'enqueue_inner_blocks_prioritized_inserter_blocks_script' ); |
Oops, something went wrong.