Directory

Add functions to customize the `Group` and `Ungroup` buttons in the block contextual menu by aurooba · Pull Request #49674 · WordPress/gutenberg · GitHub
Skip to content
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

Add functions to customize the Group and Ungroup buttons in the block contextual menu #49674

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

aurooba
Copy link
Member

@aurooba aurooba commented Apr 9, 2023

Closes #49675

This PR does not pass checks yet and doesn't have correct inline documentation yet. It's an idea I want to run past everyone first before putting in the effort to make it merge-able. It does, however, function.

What?

Add functions to customize the Group and Ungroup buttons in the block contextual menu.

Why?

Since you can change the default block used to group blocks with setGroupingBlockName, you should be able to update the corresponding label in the UI as well.

How?

This PR adds 2 publicly available functions to set and get the label for the grouping and ungrouping action in the Block Contextual Menu, sets the default values, and uses the functions to display the actual label.

Testing Instructions

  1. Create a new script in your theme or plugin and use the following code:
import {
	setGroupingBlockNameLabel,
	setUngroupingBlockNameLabel,
} from "@wordpress/blocks";
import domReady from "@wordpress/dom-ready";

domReady(function () {
	setGroupingBlockNameLabel("Nest selection in a group");
	setUngroupingBlockNameLabel("Ungroup selection");
});
  1. Open the WordPress Block Editor
  2. Add a paragraph of text.
  3. Open the Contextual block menu and see Wrap in columns as the option instead of Nest selection in a group. Select the option.
  4. Open the Contextual block men of the newly created group block, and see both options updated, Group to Nest selection in a group and Ungroup to Ungroup selection

Testing Instructions for Keyboard

Screenshots or screencast

screenshot showing the contextual menu with updated group and ungroup labels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR needs review
Development

Successfully merging this pull request may close these issues.

Make the Grouping and Ungrouping interaction labels customizable.
1 participant