Skip to content

Commit

Permalink
Add support for hiding breadcrumbs in the Site Editor (#49518)
Browse files Browse the repository at this point in the history
* Add support for hiding breadcrumbs in the Site Editor

* Use preferencesStore

* Add default showBlockBreadcrumbs as true

Matches functionality of the post editor
  • Loading branch information
richtabor authored Apr 4, 2023
1 parent bb5b306 commit e83c92e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default function Editor() {
isInserterOpen,
isListViewOpen,
showIconLabels,
showBlockBreadcrumbs,
} = useSelect( ( select ) => {
const {
getEditedPostContext,
Expand Down Expand Up @@ -94,15 +95,22 @@ export default function Editor() {
'core/edit-site',
'showIconLabels'
),
showBlockBreadcrumbs: select( preferencesStore ).get(
'core/edit-site',
'showBlockBreadcrumbs'
),
};
}, [] );
const { setEditedPostContext } = useDispatch( editSiteStore );

const isViewMode = canvasMode === 'view';
const isEditMode = canvasMode === 'edit';
const showVisualEditor = isViewMode || editorMode === 'visual';
const showBlockBreakcrumb =
isEditMode && showVisualEditor && blockEditorMode !== 'zoom-out';
const shouldShowBlockBreakcrumbs =
showBlockBreadcrumbs &&
isEditMode &&
showVisualEditor &&
blockEditorMode !== 'zoom-out';
const shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen;
const shouldShowListView = isEditMode && showVisualEditor && isListViewOpen;
const secondarySidebarLabel = isListViewOpen
Expand Down Expand Up @@ -205,7 +213,7 @@ export default function Editor() {
)
}
footer={
showBlockBreakcrumb && (
shouldShowBlockBreakcrumbs && (
<BlockBreadcrumb
rootLabelText={ __( 'Template' ) }
/>
Expand Down
7 changes: 7 additions & 0 deletions packages/edit-site/src/components/preferences-modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export default function EditSitePreferencesModal( {
) }
label={ __( 'Always open list view' ) }
/>
<EnableFeature
featureName="showBlockBreadcrumbs"
help={ __(
'Shows block breadcrumbs at the bottom of the editor.'
) }
label={ __( 'Display block breadcrumbs' ) }
/>
</PreferencesModalSection>
),
},
Expand Down
1 change: 1 addition & 0 deletions packages/edit-site/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function initializeEditor( id, settings ) {
welcomeGuide: true,
welcomeGuideStyles: true,
showListViewByDefault: false,
showBlockBreadcrumbs: true,
} );

dispatch( interfaceStore ).setDefaultComplementaryArea(
Expand Down

1 comment on commit e83c92e

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in e83c92e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4612008491
📝 Reported issues:

Please sign in to comment.