Skip to content

Commit

Permalink
Hide block toolbar using CSS when it is empty (WordPress#51779)
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks authored and sethrubenstein committed Jul 13, 2023
1 parent d196edb commit 25d82e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ const BlockToolbar = ( { hideDragHandle } ) => {
{ ! isMultiToolbar &&
isLargeViewport &&
blockEditingMode === 'default' && <BlockParentSelector /> }
<div ref={ nodeRef } { ...showMoversGestures }>
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
blockEditingMode === 'default' && (
{ ( shouldShowVisualToolbar || isMultiToolbar ) &&
blockEditingMode === 'default' && (
<div ref={ nodeRef } { ...showMoversGestures }>
<ToolbarGroup className="block-editor-block-toolbar__block-controls">
<BlockSwitcher clientIds={ blockClientIds } />
{ ! isMultiToolbar && (
Expand All @@ -142,8 +142,8 @@ const BlockToolbar = ( { hideDragHandle } ) => {
hideDragHandle={ hideDragHandle }
/>
</ToolbarGroup>
) }
</div>
</div>
) }
{ shouldShowVisualToolbar && isMultiToolbar && (
<BlockGroupToolbar />
) }
Expand Down
4 changes: 4 additions & 0 deletions packages/block-editor/src/components/block-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
}
}

&:has(.block-editor-block-toolbar:empty) {
display: none;
}

// on desktop and tablet viewports the toolbar is fixed
// on top of interface header

Expand Down

0 comments on commit 25d82e6

Please sign in to comment.