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

Post Editor: use the post type singular_name as the root Block Breadcrumb label #32609

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Jun 11, 2021

Description

#17311 introduced post type labels as the document label in the sidebar.

This PR does the same trick, but for the Block Breadcrumb.

Context: #32528 (comment)

This PR only affects the post editor. If a post type is unknown or cannot be found, we default back to __( 'Document' ).

How has this been tested?

  1. Open a post. Check that the sidebar document label is "Post" and matches the Block Breadcrumb root label, which should also be "Post"
  2. Open a page. Check that the sidebar document label is "Page" and matches the Block Breadcrumb root label, which should also be "Page"

Unit test for the selector:

npm run test-unit packages/editor/src/store/test/selectors.js

Screenshots

Screen Shot 2021-06-11 at 3 53 44 pm

Screen Shot 2021-06-11 at 3 54 15 pm

Types of changes

Adds the post type label to the Block Breadcrumb root label.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@noisysocks noisysocks added [Feature] Block Breadcrumbs Block breadcrumbs added to bottom of the editing interface [Type] Enhancement A suggestion for improvement. labels Jun 11, 2021
Copy link
Member

@kevin940726 kevin940726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM! Thank you! ❤️

packages/editor/src/store/selectors.js Outdated Show resolved Hide resolved
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also update the root when editing a template? I guess it's okay for a follow up though.

packages/editor/src/store/selectors.js Outdated Show resolved Hide resolved
@ramonjd ramonjd force-pushed the add/post-editor-use-post-type-as-breadcrumb-root-label branch from 8f18899 to 0966dd2 Compare June 11, 2021 10:52
@ramonjd
Copy link
Member Author

ramonjd commented Jun 11, 2021

Should we also update the root when editing a template? I guess it's okay for a follow up though.

Definitely!

I did want to add it to this PR however templates/template parts don't return a postType so I thought it might be neater to do the investigation/required work in a separate PR.

…ly returning null in the `getPostTypeLabel` selector.

Using `_x` so we can add context for the word Document, so we can differentiate between noun/verb.

Updated tests
@ramonjd ramonjd force-pushed the add/post-editor-use-post-type-as-breadcrumb-root-label branch from 0966dd2 to 46a21b8 Compare June 11, 2021 11:06
@ramonjd ramonjd self-assigned this Jun 11, 2021
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Let's 🚢 and iterate on template title.

Logic could probably be like in the TemplateTitle component.

@ramonjd
Copy link
Member Author

ramonjd commented Jun 11, 2021

Logic could probably be like in the TemplateTitle component.

Thank you for the thorough review and for the tip about TemplateTitle 🙇 !!

@ntsekouras ntsekouras merged commit 0216850 into WordPress:trunk Jun 11, 2021
@github-actions github-actions bot added this to the Gutenberg 10.9 milestone Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Breadcrumbs Block breadcrumbs added to bottom of the editing interface [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants