diff --git a/packages/edit-site/src/components/header/document-actions/index.js b/packages/edit-site/src/components/header/document-actions/index.js
index 979bac0d6329a1..744a886ff34e12 100644
--- a/packages/edit-site/src/components/header/document-actions/index.js
+++ b/packages/edit-site/src/components/header/document-actions/index.js
@@ -18,6 +18,7 @@ function useSecondaryText() {
return select( 'core/block-editor' ).getSelectedBlock();
} );
+ // TODO: Handle if parent is template part too.
const selectedBlockLabel =
selectedBlock?.name === 'core/template-part'
? getBlockLabel(
@@ -41,11 +42,16 @@ export default function DocumentActions( { documentTitle } ) {
// item is inactive.
const isTitleActive = ! label?.length || ! isActive;
return (
-
+
{ documentTitle ? (
<>
-
{ documentTitle }
-
- { label && (
-
- { label }
-
- ) }
+
+
+ { label ?? '' }
+
>
) : (
__( 'Loading…' )
diff --git a/packages/edit-site/src/components/header/document-actions/style.scss b/packages/edit-site/src/components/header/document-actions/style.scss
index e9f5de748646cd..e17ca10910ea4f 100644
--- a/packages/edit-site/src/components/header/document-actions/style.scss
+++ b/packages/edit-site/src/components/header/document-actions/style.scss
@@ -4,10 +4,31 @@
align-items: center;
justify-content: space-evenly;
- span {
+ .edit-site-document-actions__label {
color: $gray-700;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ transition: height 0.25s;
+
&.is-active {
color: inherit;
}
+
+ &.edit-site-document-actions__title {
+ height: 100%;
+ // Otherwise, the secondary item still takes up space with height 0:
+ flex-grow: 1;
+ }
+
+ &.edit-site-document-actions__secondary-item {
+ height: 0;
+ }
+ }
+
+ &.has-secondary-label {
+ .edit-site-document-actions__label {
+ height: 50%;
+ }
}
}