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

Editor Breadcrumb: add a rootLabelText prop #32528

Merged

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Jun 9, 2021

Description

Hi!

This PR adds a rootLabelText prop to <BlockBreadcrumb /> so that we can have flexibility to change the label, or just provide a more appropriate label for the "root" element in different editor contexts, for example the Widgets editor root level could be "Widgets".

See #32498 for context.

One day we might like to replace "Document" in the Site Editor with the name of the the site template for example.

How has this been tested?

Manually.

Apply the following patch to this branch. It adds the Breadcrumb block to the widgets editor.

Click to see the patch code
diff --git a/packages/edit-widgets/src/components/layout/interface.js b/packages/edit-widgets/src/components/layout/interface.js
index 22320cac6b..cf69328dd4 100644
--- a/packages/edit-widgets/src/components/layout/interface.js
+++ b/packages/edit-widgets/src/components/layout/interface.js
@@ -7,7 +7,10 @@ import {
 	useViewportMatch,
 } from '@wordpress/compose';
 import { close } from '@wordpress/icons';
-import { __experimentalLibrary as Library } from '@wordpress/block-editor';
+import {
+	__experimentalLibrary as Library,
+	BlockBreadcrumb,
+} from '@wordpress/block-editor';
 import { useEffect } from '@wordpress/element';
 import { useDispatch, useSelect } from '@wordpress/data';
 import {
@@ -32,6 +35,8 @@ const interfaceLabels = {
 	body: __( 'Widgets and blocks' ),
 	/* translators: accessibility text for the widgets screen settings landmark region. */
 	sidebar: __( 'Widgets settings' ),
+	/* translators: accessibility text for the widgets screen footer landmark region. */
+	footer: __( 'Widgets footer' ),
 };
 
 function Interface( { blockEditorSettings } ) {
@@ -107,6 +112,13 @@ function Interface( { blockEditorSettings } ) {
 					blockEditorSettings={ blockEditorSettings }
 				/>
 			}
+			footer={
+				! isMobileViewport && (
+					<div className="edit-widgets-layout__footer">
+						<BlockBreadcrumb rootLabelText={ __( 'Widgets' ) } />
+					</div>
+				)
+			}
 		/>
 	);
 }

Head over to /wp-admin/themes.php?page=gutenberg-widgets

Check that the breadcrumbs block appears in the footer when you select a block in the widget editor, and that the root element label is "Widgets".

Screen Shot 2021-06-09 at 11 34 23 am

Go to the Editor and Site Editor and make sure the default is "Document".

Screen Shot 2021-06-09 at 11 31 52 am

Checklist:

@ramonjd ramonjd requested a review from ellatrix as a code owner June 9, 2021 01:42
@noisysocks
Copy link
Member

If you run npm run docs:build and commit the result that should fix the lint failures.

@talldan
Copy link
Contributor

talldan commented Jun 9, 2021

One day we might like to replace "Document" in the Site Editor with the name of the the site template for example.

It might be good to switch away from using 'Document' in the post editor as well. It could use the post type's singular_name like the sidebar's tab title now does (see #17311):
Screenshot 2021-06-09 at 12 55 59 pm

Ok to treat that as a separate issue/PR though, this change probably unlocks that improvement, which is great 👍 .

@ramonjd
Copy link
Member Author

ramonjd commented Jun 9, 2021

If you run npm run docs:build and commit the result that should fix the lint failures.

TIL Thanks for the tip.

@ramonjd ramonjd force-pushed the add/blockbreadcrumb-root-label-text-prop branch from a79c052 to 7f8ff92 Compare June 9, 2021 05:28
@ramonjd
Copy link
Member Author

ramonjd commented Jun 9, 2021

Ok to treat that as a separate issue/PR though, this change probably unlocks that improvement, which is great 👍 .

Oh nice, thanks! I might take a squiz at that this week too if time permits.

… have flexibility to change the label or just provide a more appropriate label for the "root" element in different editor contexts, for example the Widgets editor root level could be "Widgets". "Document" in the Site Editor could be the name of the site template one day.

Adding snapshot tests

Rebuilding docs
@ramonjd ramonjd force-pushed the add/blockbreadcrumb-root-label-text-prop branch from 2c90cd5 to 6423601 Compare June 9, 2021 23:13
@noisysocks noisysocks added [Feature] UI Components Impacts or related to the UI component system [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement. labels Jun 10, 2021
@noisysocks noisysocks merged commit d6d9ac6 into WordPress:trunk Jun 10, 2021
@noisysocks noisysocks added the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 10, 2021
@github-actions github-actions bot added this to the Gutenberg 10.9 milestone Jun 10, 2021
@ramonjd ramonjd deleted the add/blockbreadcrumb-root-label-text-prop branch June 10, 2021 01:07
@ramonjd
Copy link
Member Author

ramonjd commented Jun 11, 2021

It might be good to switch away from using 'Document' in the post editor as well. It could use the post type's singular_name like the sidebar's tab title now does (see #17311):

I've thrown up a PR here for the post editor only.
#32609

Would love some 👀 to see if it's the right approach. Thank you!

@youknowriad youknowriad removed the Backport to WP 6.6 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Jun 14, 2021
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Jun 15, 2021
…ta 2.

This includes:

**Various**

 - Fix multi selection for nested blocks WordPress/gutenberg#32536
 - Consistently show the drop indicator while dragging blocks WordPress/gutenberg#31896
 - Fix horizontal drop indicator WordPress/gutenberg#32589
 - Fix Safari flickering issue WordPress/gutenberg#32581
 - Silence useSelect zombie bug errors WordPress/gutenberg#32088

**Template Editor**

 - Clarify the template creation modal WordPress/gutenberg#32427
 - Only add skip links for block templates WordPress/gutenberg#32451

**Widgets Editor**

 - Add block breadcrumb WordPress/gutenberg#32498 WordPress/gutenberg#32528 WordPress/gutenberg#32569
 - Saved deleted and restored widgets. WordPress/gutenberg#32534
 - Fix unsaved changes detection WordPress/gutenberg#32573
 - Fix button spacing in the header WordPress/gutenberg#32585
 - Avoid extra undo levels WordPress/gutenberg#32572
 - Move Legacy Widget block to the `@wordpress/widgets` package WordPress/gutenberg#32501
 - Fix Social Links color inheritance WordPress/gutenberg#32625
 - Use Button appender WordPress/gutenberg#32580

**Global Styles (theme.json)**
 
 - Separate the presets per origin in the block editor settings WordPress/gutenberg#32358 WordPress/gutenberg#32622
 - Use CSS Custom Properties for the preset styles WordPress/gutenberg#32627

**Performance**

 - Remove is-typing classname to improve typing performance WordPress/gutenberg#32567

Props nosolosw, jorgefilipecosta, aristath, ntsekouras, peterwilsoncc, mcsf.
See #53397.


git-svn-id: https://develop.svn.wordpress.org/trunk@51149 602fd350-edb4-49c9-b593-d223f7449a82
nylen pushed a commit to nylen/wordpress-develop-svn that referenced this pull request Jun 15, 2021
…ta 2.

This includes:

**Various**

 - Fix multi selection for nested blocks WordPress/gutenberg#32536
 - Consistently show the drop indicator while dragging blocks WordPress/gutenberg#31896
 - Fix horizontal drop indicator WordPress/gutenberg#32589
 - Fix Safari flickering issue WordPress/gutenberg#32581
 - Silence useSelect zombie bug errors WordPress/gutenberg#32088

**Template Editor**

 - Clarify the template creation modal WordPress/gutenberg#32427
 - Only add skip links for block templates WordPress/gutenberg#32451

**Widgets Editor**

 - Add block breadcrumb WordPress/gutenberg#32498 WordPress/gutenberg#32528 WordPress/gutenberg#32569
 - Saved deleted and restored widgets. WordPress/gutenberg#32534
 - Fix unsaved changes detection WordPress/gutenberg#32573
 - Fix button spacing in the header WordPress/gutenberg#32585
 - Avoid extra undo levels WordPress/gutenberg#32572
 - Move Legacy Widget block to the `@wordpress/widgets` package WordPress/gutenberg#32501
 - Fix Social Links color inheritance WordPress/gutenberg#32625
 - Use Button appender WordPress/gutenberg#32580

**Global Styles (theme.json)**
 
 - Separate the presets per origin in the block editor settings WordPress/gutenberg#32358 WordPress/gutenberg#32622
 - Use CSS Custom Properties for the preset styles WordPress/gutenberg#32627

**Performance**

 - Remove is-typing classname to improve typing performance WordPress/gutenberg#32567

Props nosolosw, jorgefilipecosta, aristath, ntsekouras, peterwilsoncc, mcsf.
See #53397.


git-svn-id: https://develop.svn.wordpress.org/trunk@51149 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Jun 15, 2021
…ta 2.

This includes:

**Various**

 - Fix multi selection for nested blocks WordPress/gutenberg#32536
 - Consistently show the drop indicator while dragging blocks WordPress/gutenberg#31896
 - Fix horizontal drop indicator WordPress/gutenberg#32589
 - Fix Safari flickering issue WordPress/gutenberg#32581
 - Silence useSelect zombie bug errors WordPress/gutenberg#32088

**Template Editor**

 - Clarify the template creation modal WordPress/gutenberg#32427
 - Only add skip links for block templates WordPress/gutenberg#32451

**Widgets Editor**

 - Add block breadcrumb WordPress/gutenberg#32498 WordPress/gutenberg#32528 WordPress/gutenberg#32569
 - Saved deleted and restored widgets. WordPress/gutenberg#32534
 - Fix unsaved changes detection WordPress/gutenberg#32573
 - Fix button spacing in the header WordPress/gutenberg#32585
 - Avoid extra undo levels WordPress/gutenberg#32572
 - Move Legacy Widget block to the `@wordpress/widgets` package WordPress/gutenberg#32501
 - Fix Social Links color inheritance WordPress/gutenberg#32625
 - Use Button appender WordPress/gutenberg#32580

**Global Styles (theme.json)**
 
 - Separate the presets per origin in the block editor settings WordPress/gutenberg#32358 WordPress/gutenberg#32622
 - Use CSS Custom Properties for the preset styles WordPress/gutenberg#32627

**Performance**

 - Remove is-typing classname to improve typing performance WordPress/gutenberg#32567

Props nosolosw, jorgefilipecosta, aristath, ntsekouras, peterwilsoncc, mcsf.
See #53397.

Built from https://develop.svn.wordpress.org/trunk@51149


git-svn-id: http://core.svn.wordpress.org/trunk@50758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Jun 15, 2021
…ta 2.

This includes:

**Various**

 - Fix multi selection for nested blocks WordPress/gutenberg#32536
 - Consistently show the drop indicator while dragging blocks WordPress/gutenberg#31896
 - Fix horizontal drop indicator WordPress/gutenberg#32589
 - Fix Safari flickering issue WordPress/gutenberg#32581
 - Silence useSelect zombie bug errors WordPress/gutenberg#32088

**Template Editor**

 - Clarify the template creation modal WordPress/gutenberg#32427
 - Only add skip links for block templates WordPress/gutenberg#32451

**Widgets Editor**

 - Add block breadcrumb WordPress/gutenberg#32498 WordPress/gutenberg#32528 WordPress/gutenberg#32569
 - Saved deleted and restored widgets. WordPress/gutenberg#32534
 - Fix unsaved changes detection WordPress/gutenberg#32573
 - Fix button spacing in the header WordPress/gutenberg#32585
 - Avoid extra undo levels WordPress/gutenberg#32572
 - Move Legacy Widget block to the `@wordpress/widgets` package WordPress/gutenberg#32501
 - Fix Social Links color inheritance WordPress/gutenberg#32625
 - Use Button appender WordPress/gutenberg#32580

**Global Styles (theme.json)**
 
 - Separate the presets per origin in the block editor settings WordPress/gutenberg#32358 WordPress/gutenberg#32622
 - Use CSS Custom Properties for the preset styles WordPress/gutenberg#32627

**Performance**

 - Remove is-typing classname to improve typing performance WordPress/gutenberg#32567

Props nosolosw, jorgefilipecosta, aristath, ntsekouras, peterwilsoncc, mcsf.
See #53397.

Built from https://develop.svn.wordpress.org/trunk@51149


git-svn-id: https://core.svn.wordpress.org/trunk@50758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
F-Wilke pushed a commit to FiliagoDev/WordPress that referenced this pull request Jul 31, 2021
…ta 2.

This includes:

**Various**

 - Fix multi selection for nested blocks WordPress/gutenberg#32536
 - Consistently show the drop indicator while dragging blocks WordPress/gutenberg#31896
 - Fix horizontal drop indicator WordPress/gutenberg#32589
 - Fix Safari flickering issue WordPress/gutenberg#32581
 - Silence useSelect zombie bug errors WordPress/gutenberg#32088

**Template Editor**

 - Clarify the template creation modal WordPress/gutenberg#32427
 - Only add skip links for block templates WordPress/gutenberg#32451

**Widgets Editor**

 - Add block breadcrumb WordPress/gutenberg#32498 WordPress/gutenberg#32528 WordPress/gutenberg#32569
 - Saved deleted and restored widgets. WordPress/gutenberg#32534
 - Fix unsaved changes detection WordPress/gutenberg#32573
 - Fix button spacing in the header WordPress/gutenberg#32585
 - Avoid extra undo levels WordPress/gutenberg#32572
 - Move Legacy Widget block to the `@wordpress/widgets` package WordPress/gutenberg#32501
 - Fix Social Links color inheritance WordPress/gutenberg#32625
 - Use Button appender WordPress/gutenberg#32580

**Global Styles (theme.json)**
 
 - Separate the presets per origin in the block editor settings WordPress/gutenberg#32358 WordPress/gutenberg#32622
 - Use CSS Custom Properties for the preset styles WordPress/gutenberg#32627

**Performance**

 - Remove is-typing classname to improve typing performance WordPress/gutenberg#32567

Props nosolosw, jorgefilipecosta, aristath, ntsekouras, peterwilsoncc, mcsf.
See #53397.

Built from https://develop.svn.wordpress.org/trunk@51149


git-svn-id: http://core.svn.wordpress.org/trunk@50758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Package] Block editor /packages/block-editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants