-
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
Try: Rewrite Block Rename UI with hooks #55629
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
|
I found PR #55604 for the |
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.BlockEdit
hook and inject the Rename modal into theBlockSettingsMenuControls
slot.In this PR, the
editor.BlockEdit
hook only renders the text field in the Advanced panel.Instead, the menu item to display the rename modal UI is added to the
BlockSettingsMenuControls
slot 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