Try: Rewrite Block Rename UI with hooks#55629
Closed
t-hamano wants to merge 3 commits into
Closed
Conversation
|
Warning: Type of PR label error To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. |
|
Size Change: +23 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 71e9a2e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6642776595
|
Contributor
Author
|
I found PR #55604 for the |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes ##55612
What?
This PR uses a hook to rewrite a series of processes to solve the problem that the Rename menu is not displayed in the popover menu of blocks that are not selected in the List View.
Why?
Thanks to #54426, most blocks now support renaming. However, this resulted in a performance drop, so #55250 changed the component to only render when the block is selected.
This is correct behavior in the Advanced panel of the block sidebar, but in the List View I think the Rename menu should be visible like any other item, even if no block is selected.
How?
In trunk, we render a text field in the Advanced panel via the
editor.BlockEdithook and inject the Rename modal into theBlockSettingsMenuControlsslot.In this PR, the
editor.BlockEdithook only renders the text field in the Advanced panel.Instead, the menu item to display the rename modal UI is added to the
BlockSettingsMenuControlsslot itself. This implementation and file structure is very similar to the Block Locking implementation.This allows renaming even if the block is not selected in the list view, and there should be no performance degradation.
Testing Instructions
Perf test
To see locally how it affects performance, run the following commands on both the trunk branch and this PR:
Below are the average values of three tests run on both branches. This value may depend on your local environment, but all metrics should be approximately the same.
This PR
trunk