diff --git a/packages/base-styles/_z-index.scss b/packages/base-styles/_z-index.scss index 80794990713ff3..9e8cc1161fe599 100644 --- a/packages/base-styles/_z-index.scss +++ b/packages/base-styles/_z-index.scss @@ -179,8 +179,8 @@ $z-layers: ( // Appear under the customizer heading UI, but over anything else. ".customize-widgets__topbar": 8, - // Appear under the topbar. - ".customize-widgets__block-toolbar": 7, + // Appear over the topbar of both editor and customizer. + ".customize-widgets__block-toolbar": 10, ); @function z-index( $key ) { diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md index a8a19f6f830211..c75e7875442477 100644 --- a/packages/block-editor/README.md +++ b/packages/block-editor/README.md @@ -244,6 +244,7 @@ _Parameters_ - _$0_ `Object`: Props. - _$0.children_ `Object`: The block content and style container. - _$0.\_\_unstableContentRef_ `Object`: Ref holding the content scroll container. +- _$0.\_\_experimentalStickyTop_ `Object`: Offset for the top position of toolbars. # **BlockVerticalAlignmentControl** diff --git a/packages/block-editor/src/components/block-tools/block-contextual-toolbar.js b/packages/block-editor/src/components/block-tools/block-contextual-toolbar.js index a8e55abe6f408b..460d6fc5ded5cb 100644 --- a/packages/block-editor/src/components/block-tools/block-contextual-toolbar.js +++ b/packages/block-editor/src/components/block-tools/block-contextual-toolbar.js @@ -17,7 +17,13 @@ import NavigableToolbar from '../navigable-toolbar'; import BlockToolbar from '../block-toolbar'; import { store as blockEditorStore } from '../../store'; -function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) { +function BlockContextualToolbar( { + focusOnMount, + isFixed, + __experimentalStickyTop, + style = {}, + ...props +} ) { const { blockType, hasParents, showParentSelector } = useSelect( ( select ) => { const { @@ -59,12 +65,17 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) { 'is-fixed': isFixed, } ); + if ( __experimentalStickyTop ) { + style.top = __experimentalStickyTop; + } + return ( diff --git a/packages/block-editor/src/components/block-tools/block-popover.js b/packages/block-editor/src/components/block-tools/block-popover.js index 8371cfff9bbba8..de6094a6989f2e 100644 --- a/packages/block-editor/src/components/block-tools/block-popover.js +++ b/packages/block-editor/src/components/block-tools/block-popover.js @@ -54,6 +54,7 @@ function BlockPopover( { capturingClientId, __unstablePopoverSlot, __unstableContentRef, + __experimentalStickyTop, } ) { const { isNavigationMode, @@ -213,6 +214,7 @@ function BlockPopover( { // Observe movement for block animations (especially horizontal). __unstableObserveElement={ node } shouldAnchorIncludePadding + __experimentalStickyTop={ __experimentalStickyTop } > { ( shouldShowContextualToolbar || isToolbarForced ) && (
); } diff --git a/packages/block-editor/src/components/block-tools/index.js b/packages/block-editor/src/components/block-tools/index.js index 04302c68e173f6..16b2b2b1a89116 100644 --- a/packages/block-editor/src/components/block-tools/index.js +++ b/packages/block-editor/src/components/block-tools/index.js @@ -19,11 +19,16 @@ import { usePopoverScroll } from './use-popover-scroll'; * insertion point and a slot for the inline rich text toolbar). Must be wrapped * around the block content and editor styles wrapper or iframe. * - * @param {Object} $0 Props. - * @param {Object} $0.children The block content and style container. - * @param {Object} $0.__unstableContentRef Ref holding the content scroll container. + * @param {Object} $0 Props. + * @param {Object} $0.children The block content and style container. + * @param {Object} $0.__unstableContentRef Ref holding the content scroll container. + * @param {Object} $0.__experimentalStickyTop Offset for the top position of toolbars. */ -export default function BlockTools( { children, __unstableContentRef } ) { +export default function BlockTools( { + children, + __unstableContentRef, + __experimentalStickyTop, +} ) { const isLargeViewport = useViewportMatch( 'medium' ); const hasFixedToolbar = useSelect( ( select ) => select( blockEditorStore ).getSettings().hasFixedToolbar, @@ -33,11 +38,17 @@ export default function BlockTools( { children, __unstableContentRef } ) { return ( { ( hasFixedToolbar || ! isLargeViewport ) && ( - + ) } { /* Even if the toolbar is fixed, the block popover is still needed for navigation mode. */ } - + { /* Used for the inline rich text toolbar. */ } - + diff --git a/packages/customize-widgets/src/controls/style.scss b/packages/customize-widgets/src/controls/style.scss index 57bc56d9fcbbf3..de905da202a153 100644 --- a/packages/customize-widgets/src/controls/style.scss +++ b/packages/customize-widgets/src/controls/style.scss @@ -12,13 +12,13 @@ // Override the inline styles added via JS that make the section title // sticky feature work. The customize widget block-editor disables this // sticky title. - padding-top: 10px !important; + padding-top: 12px !important; .customize-section-title { // Disable the sticky title. `!important` as this overrides inline // styles added via JavaScript. position: static !important; - top: 0 !important; width: unset !important; + margin-top: -12px !important; } }