Skip to content

Commit

Permalink
Navigation: Try always showing appender even when child is selected. (#…
Browse files Browse the repository at this point in the history
…37637)

* Navigation: Try always showing appender even when child is selected.

* Remove broken custom appender logic.

Co-authored-by: tellthemachines <[email protected]>
  • Loading branch information
jasmussen and tellthemachines authored Feb 4, 2022
1 parent 60df02e commit 87d7e17
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
2 changes: 0 additions & 2 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function Navigation( {
hasSubmenuIndicatorSetting = true,
hasColorSettings = true,
customPlaceholder: CustomPlaceholder = null,
customAppender: CustomAppender = null,
} ) {
const {
openSubmenusOnClick,
Expand Down Expand Up @@ -696,7 +695,6 @@ function Navigation( {
<NavigationInnerBlocks
isVisible={ ! isPlaceholderShown }
clientId={ clientId }
appender={ CustomAppender }
hasCustomPlaceholder={
!! CustomPlaceholder
}
Expand Down
19 changes: 16 additions & 3 deletions packages/block-library/src/navigation/edit/inner-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { useEntityBlockEditor } from '@wordpress/core-data';
import {
useInnerBlocksProps,
InnerBlocks,
__experimentalBlockContentOverlay as BlockContentOverlay,
store as blockEditorStore,
} from '@wordpress/block-editor';
Expand Down Expand Up @@ -39,7 +40,6 @@ const LAYOUT = {
export default function NavigationInnerBlocks( {
isVisible,
clientId,
appender: CustomAppender,
hasCustomPlaceholder,
orientation,
} ) {
Expand Down Expand Up @@ -95,7 +95,6 @@ export default function NavigationInnerBlocks( {
const parentOrChildHasSelection =
isSelected ||
( isImmediateParentOfSelectedBlock && ! selectedBlockHasDescendants );
const appender = isVisible && parentOrChildHasSelection ? undefined : false;

const placeholder = useMemo( () => <PlaceholderPreview />, [] );

Expand All @@ -111,7 +110,21 @@ export default function NavigationInnerBlocks( {
__experimentalDefaultBlock: DEFAULT_BLOCK,
__experimentalDirectInsert: shouldDirectInsert,
orientation,
renderAppender: CustomAppender || appender,

// As an exception to other blocks which feature nesting, show
// the block appender even when a child block is selected.
// This should be a temporary fix, to be replaced by improvements to
// the sibling inserter.
// See https://github.com/WordPress/gutenberg/issues/37572.
renderAppender:
isSelected ||
( isImmediateParentOfSelectedBlock &&
! selectedBlockHasDescendants ) ||
// Show the appender while dragging to allow inserting element between item and the appender.
parentOrChildHasSelection
? InnerBlocks.ButtonBlockAppender
: false,

// Template lock set to false here so that the Nav
// Block on the experimental menus screen does not
// inherit templateLock={ 'all' }.
Expand Down
19 changes: 18 additions & 1 deletion packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,25 @@ $color-control-label-height: 20px;
}
}

// Override inner padding on default appender.
// This should be a temporary fix, to be replaced by improvements to
// the sibling inserter.
// See https://github.com/WordPress/gutenberg/issues/37572.
.wp-block-navigation .block-editor-button-block-appender {
justify-content: flex-start;
background-color: $gray-900;
color: $white;

// This needs specificity to override an inherited padding.
// That source padding in turn has high specificity to protect
// from theme CSS bleed.
&.block-editor-button-block-appender.block-editor-button-block-appender {
padding: 0;
}
}

.wp-block-navigation .wp-block .wp-block .block-editor-button-block-appender {
background-color: transparent;
color: $gray-900;
}


Expand Down

0 comments on commit 87d7e17

Please sign in to comment.