Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c8e10ba
Inserter: Show inline inserter before the first block and in the post…
shail-mehta Sep 1, 2026
64605dc
Added Changelog Entry
shail-mehta Sep 1, 2026
5e0aead
Restore guard for nested list
shail-mehta Sep 1, 2026
3ffaf94
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 1, 2026
fdac155
Fix Unit Test
shail-mehta Sep 2, 2026
1fe42e1
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 2, 2026
b838090
Fix Lint
shail-mehta Sep 2, 2026
7851067
fix lint
shail-mehta Sep 2, 2026
a8f0068
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 2, 2026
d037d2e
fix lint
shail-mehta Sep 2, 2026
67e5790
Apply Feedback
shail-mehta Sep 2, 2026
aa28d8e
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 2, 2026
21ff161
Fix Unit Test
shail-mehta Sep 3, 2026
e8b99b7
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 3, 2026
8e80607
Fix Lint
shail-mehta Sep 3, 2026
9e6eabe
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 3, 2026
428183e
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 6, 2026
4507f36
Merge branch trunk into fix/inline-inserter-top-position
shail-mehta Sep 18, 2026
253c206
Fix title-gap inserter overlay stealing first-block clicks
Sep 18, 2026
d41a525
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 18, 2026
0bf960f
Update CHANGELOG.md entry
shail-mehta Sep 18, 2026
a9bd20f
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 18, 2026
84bc2d1
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 22, 2026
9b8add3
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 23, 2026
42c2b36
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Sep 25, 2026
462bc2d
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Oct 7, 2026
cb5e243
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Oct 7, 2026
af29720
Inserter: Stop title-gap overlay stealing first-block clicks
shail-mehta Oct 7, 2026
355557f
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Oct 7, 2026
0038362
moved changelog in unreleased section
shail-mehta Oct 7, 2026
9309fa1
Revise CHANGELOG for enhancements and bug fixes
shail-mehta Oct 7, 2026
61ffbef
Update CHANGELOG.md with recent changes
shail-mehta Oct 7, 2026
f038749
Add inline inserter enhancement to changelog
shail-mehta Oct 7, 2026
bd96292
removed unintended changes
shail-mehta Oct 7, 2026
efe82a5
Merge branch 'trunk' into fix/inline-inserter-top-position
shail-mehta Oct 14, 2026
0b43d7c
Clean up CHANGELOG.md formatting
shail-mehta Oct 14, 2026
7e5c1bf
Merge remote-tracking branch 'origin/trunk' into fix/inline-inserter-…
shail-mehta Nov 1, 2026
02929b0
Move block-editor #82301 changelog entry to Unreleased
shail-mehta Nov 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Enhancements

- Borders: rename the "Border & Shadow" panel to "Borders", whichever of its controls are available, and always show the Border and Shadow controls' visible labels. A stable panel title is what lets the Border label render unconditionally, so its "Unlink sides" toggle lines up with the border radius one ([#82163](https://github.com/WordPress/gutenberg/pull/82163)).
- In-between inserter: Opt-in `placeBeforeFirstBlock` places the before-first (title-gap) insertion popover above the first block so the "+" does not overlap it ([#82301](https://github.com/WordPress/gutenberg/pull/82301)).

### Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ export function useInBetweenInserter() {
const index = getBlockIndex( clientId );

// Don't show the in-between inserter before the first block in
// the list (preserves the original behaviour).
// the list. Insertion at index 0 in the post editor is handled
// separately via the title gap inserter.
if ( index === 0 ) {
hideInsertionPoint();
return;
Expand Down
43 changes: 43 additions & 0 deletions packages/block-editor/src/components/block-popover/inbetween.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@

const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;

/**

Check failure on line 12 in packages/block-editor/src/components/block-popover/inbetween.jsx

View workflow job for this annotation

GitHub Actions / All (Node.js 24 on Linux)

Expected JSDoc block lines to be aligned.
* Positions a popover in the gap between two sibling blocks (or before/after
* the first/last block) for the in-between insertion point UI.
*
* @param {Object} props Component props.
* @param {string} props.previousClientId Client id of the block before the gap.
* @param {string} props.nextClientId Client id of the block after the gap.
* @param {import('react').ReactNode} props.children Popover contents.
* @param {string} props.__unstablePopoverSlot Optional popover slot name.
* @param {Object} props.__unstableContentRef Ref to the scrollable canvas content.
* @param {string} props.operation Insertion operation type.
* @param {string} props.nearestSide Preferred side for group operations.
* @param {boolean} props.placeBeforeFirstBlock When true and there is no previous block, place the popover above the first block (title-gap inserter).
* @return {JSX.Element|null} In-between popover, or null when not visible.

Check failure on line 25 in packages/block-editor/src/components/block-popover/inbetween.jsx

View workflow job for this annotation

GitHub Actions / All (Node.js 24 on Linux)

The type 'JSX' is undefined.
*/
function BlockPopoverInbetween( {
previousClientId,
nextClientId,
Expand All @@ -17,6 +32,10 @@
__unstableContentRef,
operation = 'insert',
nearestSide = 'right',
// When true and there is no previous block, place the popover in the gap
// above the first block (title-gap inserter). Leave false for drag-and-drop
// and other index-0 indicators that expect a zero-height line.
placeBeforeFirstBlock = false,
...props
} ) {
// This is a temporary hack to get the inbetween inserter to recompute properly.
Expand Down Expand Up @@ -113,6 +132,29 @@
nextRect && previousRect
? ( previousRect.left + nextRect.left ) / 2
: ( previousRect || nextRect ).left;

// Title-gap inserter only: lift the popover into the gap
// above the first block so the "+" does not overlap it.
if (
placeBeforeFirstBlock &&
! previousRect &&
nextRect &&
nextElement
) {
const { defaultView } = nextElement.ownerDocument;
const marginTop = defaultView
? parseFloat(
defaultView.getComputedStyle( nextElement )
.marginTop
) || 0
: 0;
// Match $button-size-small so a centered "+" sits fully
// above the block when margin is 0.
const minInserterGap = 24;
const gapHeight = Math.max( marginTop, minInserterGap );
top = nextRect.top - gapHeight;
height = gapHeight;
}
} else {
top = previousRect ? previousRect.top : nextRect.top;
height = previousRect
Expand Down Expand Up @@ -153,6 +195,7 @@
isVisible,
operation,
nearestSide,
placeBeforeFirstBlock,
] );

const popoverScrollRef = usePopoverScroll( __unstableContentRef );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
export const InsertionPointOpenRef = createContext();
InsertionPointOpenRef.displayName = 'InsertionPointOpenRefContext';

/**
* Renders the in-between insertion point popover, optionally with a quick
* inserter when `__unstableWithInserter` is set on the insertion point.
*
* @param {Object} props Component props.
* @param {string} props.__unstablePopoverSlot Optional popover slot name.
* @param {Object} props.__unstableContentRef Ref to the scrollable canvas content.
* @param {string} props.operation Insertion operation type.
* @param {string} props.nearestSide Preferred side for group operations.
* @return {JSX.Element|null} Insertion point UI, or null when hidden.

Check failure on line 29 in packages/block-editor/src/components/block-tools/insertion-point.jsx

View workflow job for this annotation

GitHub Actions / All (Node.js 24 on Linux)

The type 'JSX' is undefined.
*/
function InbetweenInsertionPointPopover( {
__unstablePopoverSlot,
__unstableContentRef,
Expand Down Expand Up @@ -171,6 +182,8 @@
orientationClassname
);

const placeBeforeFirstBlock = isInserterShown && ! previousClientId;

return (
<BlockPopoverInbetween
previousClientId={ previousClientId }
Expand All @@ -179,6 +192,7 @@
__unstableContentRef={ __unstableContentRef }
operation={ operation }
nearestSide={ nearestSide }
placeBeforeFirstBlock={ placeBeforeFirstBlock }
>
<motion.div
layout={ ! disableMotion }
Expand All @@ -193,6 +207,7 @@
onFocus={ onFocus }
className={ clsx( className, {
'is-with-inserter': isInserterShown,
'is-before-first-block': placeBeforeFirstBlock,
} ) }
onHoverEnd={ maybeHideInserterPoint }
>
Expand Down
4 changes: 4 additions & 0 deletions packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancements

- Post editor: Show the inline inserter in the gap between the post title and the first block ([#82301](https://github.com/WordPress/gutenberg/pull/82301)).

### Breaking Changes

- `PluginMoreMenuItem`, `PluginSidebarMoreMenuItem`: Items render with the `Menu` component of `@wordpress/ui` instead of `MenuItem`. A link item honors only `target="_blank"` ([#81564](https://github.com/WordPress/gutenberg/pull/81564)).
Expand Down
16 changes: 16 additions & 0 deletions packages/editor/src/components/visual-editor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
} from '../../store/constants';
import { useZoomOutModeExit } from './use-zoom-out-mode-exit';
import { usePaddingAppender } from './use-padding-appender';
import { useTitleGapInserter } from './use-title-gap-inserter';
import { useEditContentOnlySectionExit } from './use-edit-content-only-section-exit';
import { SyncConnectionErrorModal } from '../sync-connection-error-modal';

Expand Down Expand Up @@ -117,6 +118,17 @@
return Math.min( Math.round( width / aspectRatio ), containerSize.height );
}

/**

Check failure on line 121 in packages/editor/src/components/visual-editor/index.jsx

View workflow job for this annotation

GitHub Actions / All (Node.js 24 on Linux)

Expected JSDoc block lines to be aligned.
* Renders the post or site editor visual canvas, including the iframe,
* block list, and post title when in post-only mode.
*
* @param {Object} props Component props.
* @param {boolean} props.autoFocus Whether the canvas should take focus on mount.
* @param {Object} props.iframeProps Props forwarded to the editor canvas iframe.
* @param {Object} props.contentRef Ref merged onto the canvas content node.
* @param {string} props.className Optional extra class name for the wrapper.
* @return {JSX.Element} Visual editor canvas.
*/
function VisualEditor( {
// Ideally as we unify post and site editors, we won't need these props.
autoFocus,
Expand Down Expand Up @@ -379,6 +391,9 @@
const [ paddingAppenderRef, paddingStyle ] = usePaddingAppender(
! isPreview && renderingMode === 'post-only' && ! isDesignPostType
);
const titleGapInserterRef = useTitleGapInserter(
! isPreview && renderingMode === 'post-only' && ! isDesignPostType
);

const shouldConstrainCanvasHeight =
enableResizing &&
Expand Down Expand Up @@ -444,6 +459,7 @@
} ),
useZoomOutModeExit(),
paddingAppenderRef,
titleGapInserterRef,
useEditContentOnlySectionExit(),
] );

Expand Down
11 changes: 11 additions & 0 deletions packages/editor/src/components/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@
padding: 6px;
}
}

// Title-gap inserter only (`is-before-first-block`). Limit hit-testing to
// the "+" so the overlay does not steal clicks on the first block.
.block-editor-block-list__insertion-point.is-before-first-block {
pointer-events: none;

.block-editor-block-list__insertion-point-inserter,
.block-editor-block-list__insertion-point-inserter * {
pointer-events: all;
}
}
}
166 changes: 166 additions & 0 deletions packages/editor/src/components/visual-editor/use-title-gap-inserter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import { useRefEffect } from '@wordpress/compose';
import { useRegistry, useSelect } from '@wordpress/data';
import { store as blockEditorStore } from '@wordpress/block-editor';
import { unlock } from '../../lock-unlock';

const TITLE_WRAPPER_SELECTOR = '.editor-visual-editor__post-title-wrapper';
const BLOCK_LIST_LAYOUT_SELECTOR =
'.block-editor-block-list__layout.is-root-container';
const QUICK_INSERTER_SELECTOR = '.block-editor-inserter__quick-inserter';
const EXPANDED_INSERTER_TOGGLE_SELECTOR =
'.block-editor-block-list__insertion-point-inserter .block-editor-inserter__toggle[aria-expanded="true"]';

/**
* Whether the title-gap inserter menu is open or opening.
* The insertion point and quick inserter render in the parent document
* (outside the canvas iframe); the toggle's aria-expanded covers the
* brief gap before the menu mounts.
*
* @param {Document} doc Canvas document.
* @return {boolean} True when the quick inserter is open or opening.
*/
function isTitleGapInserterMenuActive( doc ) {
const parentDoc = doc.defaultView?.frameElement?.ownerDocument;
const docs = parentDoc ? [ doc, parentDoc ] : [ doc ];

return docs.some(
( checkDoc ) =>
!! checkDoc.querySelector( QUICK_INSERTER_SELECTOR ) ||
!! checkDoc.querySelector( EXPANDED_INSERTER_TOGGLE_SELECTOR )
);
}

/**
* Hides the title-gap insertion point when it is the visible cue.
*
* @param {Object} registry Data registry.
* @return {void}
*/
function hideTitleGapInsertionPoint( registry ) {
const blockEditorSelect = registry.select( blockEditorStore );
const insertionPoint = blockEditorSelect.isBlockInsertionPointVisible()
? blockEditorSelect.getBlockInsertionPoint()
: null;

// Hide only the title-gap insertion point so we don't dismiss
// unrelated in-between inserters. Leaving it visible lets the
// pointer-events overlay steal clicks on the first block
// (e.g. shift+click multi-selection inside a Group).
if (
insertionPoint?.__unstableWithInserter &&
insertionPoint.rootClientId === '' &&
insertionPoint.index === 0
) {
registry.dispatch( blockEditorStore ).hideInsertionPoint();
}
}

/**
* Shows the block inserter when hovering the gap between the post title
* and the first block in the post editor.
*
* @param {boolean} enabled Whether the hook is enabled.
* @return {import('react').RefCallback} Ref callback that attaches the hover listener.
*/
export function useTitleGapInserter( enabled ) {
const registry = useRegistry();
const isDisabled = useSelect( ( select ) => {
const { getSettings, isZoomOut } = unlock( select( blockEditorStore ) );
const settings = getSettings();
return (
settings.isDistractionFree || settings.isPreviewMode || isZoomOut()
);
}, [] );

return useRefEffect(
( node ) => {
if ( ! enabled || isDisabled ) {
return;
}

/**
* Shows or hides the title-gap insertion point from pointer position.
*
* @param {MouseEvent} event Pointer move event from the canvas.
* @return {void}
*/
function onMouseMove( event ) {
const blockEditorSelect = registry.select( blockEditorStore );
const { getBlockOrder, isMultiSelecting, getTemplateLock } =
unlock( blockEditorSelect );
const { showInsertionPoint, hideInsertionPoint } =
registry.dispatch( blockEditorStore );

if ( isMultiSelecting() ) {
return;
}

if ( getTemplateLock( '' ) ) {
hideInsertionPoint();
return;
}

const blockOrder = getBlockOrder( '' );
if ( blockOrder.length === 0 ) {
hideInsertionPoint();
return;
}

const { ownerDocument } = node;
const titleWrapper = ownerDocument.querySelector(
TITLE_WRAPPER_SELECTOR
);
const blockListLayout = ownerDocument.querySelector(
BLOCK_LIST_LAYOUT_SELECTOR
);

if ( ! titleWrapper || ! blockListLayout ) {
return;
}

const firstBlock =
blockListLayout.querySelector( ':scope > .wp-block' );
if ( ! firstBlock ) {
hideInsertionPoint();
return;
}

const titleRect = titleWrapper.getBoundingClientRect();
const firstBlockRect = firstBlock.getBoundingClientRect();
const layoutRect = blockListLayout.getBoundingClientRect();
const { clientY, clientX } = event;

const isInTitleGap =
clientY > titleRect.bottom &&
clientY < firstBlockRect.top &&
clientX >= layoutRect.left &&
clientX <= layoutRect.right;

if ( isInTitleGap ) {
showInsertionPoint( '', 0, {
__unstableWithInserter: true,
} );
return;
}

// Keep the insertion point mounted while the quick inserter
// menu is open or opening; hiding it would unmount the menu.
if ( isTitleGapInserterMenuActive( ownerDocument ) ) {
return;
}

hideTitleGapInsertionPoint( registry );
}

node.addEventListener( 'mousemove', onMouseMove );

return () => {
node.removeEventListener( 'mousemove', onMouseMove );
// Clear a stuck title-gap cue when the hook disables (e.g.
// distraction-free / zoom-out) or the effect re-runs.
hideTitleGapInsertionPoint( registry );
};
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
},
[ enabled, isDisabled, registry ]
);
}
Loading
Loading