Skip to content

Commit

Permalink
Hide block toolbar using CSS when it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Jun 23, 2023
1 parent 5fa3f81 commit 405df35
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 405df35

Please sign in to comment.