Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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 @@ -4,6 +4,7 @@

### Bug Fixes

- Inserter: Keep the hovered block preview inside the viewport, so a tall preview in a short window is no longer clipped ([#82060](https://github.com/WordPress/gutenberg/pull/82060)).
- Client-side media processing: Refuse a batch of more than one file when the caller only takes one, such as a Cover block placeholder, matching what the server-side upload path already did. Every dropped file was uploaded instead, and the block kept whichever one finished last ([#82041](https://github.com/WordPress/gutenberg/issues/82041)).

## 17.0.0 (2026-08-26)
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ function InserterMenu(
<Popover
className="block-editor-inserter__preview-container__popover"
placement="right-start"
offset={ 16 }
offset={ { mainAxis: 16, crossAxis: 16 } }
focusOnMount={ false }
animate={ false }
>
Expand Down
4 changes: 0 additions & 4 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ $block-inserter-tabs-height: 44px;
}
}

.block-editor-inserter__preview-container__popover {
top: $grid-unit-20 !important;
}

.block-editor-inserter__preview-container {
display: none;
width: $sidebar-width;
Expand Down
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### TypeScript
Comment thread
ciampo marked this conversation as resolved.
Resolved

- `Popover`: Widen `offset` to also accept an object with separate main and cross axis offsets. The same applies to `BorderBoxControl`'s `popoverOffset` prop ([#82060](https://github.com/WordPress/gutenberg/pull/82060)).

## 40.0.0 (2026-08-26)

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ The available base placements are 'top', 'right', 'bottom', 'left'. Each of thes

- Required: No

### `popoverOffset`: `number`
### `popoverOffset`: `number | { mainAxis?: number; crossAxis?: number }`

The space between the popover and the control wrapper.
The space between the popover and the control wrapper. A number displaces the popover along its main axis; pass an object to also displace it along its cross axis.

- Required: No

Expand Down
8 changes: 6 additions & 2 deletions packages/components/src/border-box-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export type BorderBoxControlProps = ColorProps &
*/
popoverPlacement?: PopoverProps[ 'placement' ];
/**
* The space between the popover and the control wrapper.
* The space between the popover and the control wrapper. A number
* displaces the popover along its main axis; pass an object to also
* displace it along its cross axis.
*/
popoverOffset?: PopoverProps[ 'offset' ];
/**
Expand Down Expand Up @@ -83,7 +85,9 @@ export type SplitControlsProps = ColorProps &
*/
popoverPlacement?: PopoverProps[ 'placement' ];
/**
* The space between the popover and the control wrapper.
* The space between the popover and the control wrapper. A number
* displaces the popover along its main axis; pass an object to also
* displace it along its cross axis.
*/
popoverOffset?: PopoverProps[ 'offset' ];
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/popover/README.md
Comment thread
ciampo marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ Used to show/hide the arrow that points at the popover's anchor.
- Required: No
- Default: `true`

### `offset`: `number`
### `offset`: `number | { mainAxis?: number; crossAxis?: number }`

The distance (in px) between the anchor and the popover.
The distance (in px) between the anchor and the popover. A number displaces the popover along its main axis; pass an object to also displace it along its cross axis.

- Required: No

Expand Down
23 changes: 23 additions & 0 deletions packages/components/src/popover/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,29 @@ describe( 'Popover', () => {
} );
} );

describe( 'offset', () => {
it( 'should displace the popover along its cross axis when passed an offset object', async () => {
Comment thread
ciampo marked this conversation as resolved.
Resolved
render(
<Popover
placement="right-start"
offset={ { mainAxis: 16, crossAxis: 24 } }
animate={ false }
flip={ false }
shift={ false }
data-testid="popover-element"
>
Hello
</Popover>
);
const popover = screen.getByTestId( 'popover-element' );

await waitFor( () => expect( popover ).toBeVisible() );
expect( popover ).toHaveStyle(
'transform: translateX(16px) translateY(24px)'
);
} );
} );

describe( 'style', () => {
it( 'outputs inline styles added through the style prop in addition to built-in popover positioning styles', async () => {
render(
Expand Down
12 changes: 9 additions & 3 deletions packages/components/src/popover/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ export type PopoverProps = {
*/
noArrow?: boolean;
/**
* The distance (in px) between the anchor and the popover.
*/
offset?: number;
* The distance (in px) between the anchor and the popover. Pass an object to
* also displace the popover along its cross axis.
*/
offset?:
| number
| {
mainAxis?: number;
crossAxis?: number;
};
/**
* A callback invoked when the popover should be closed.
*/
Expand Down
32 changes: 32 additions & 0 deletions test/e2e/specs/editor/various/inserting-blocks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,38 @@ test.describe( 'Inserting blocks (@firefox, @webkit)', () => {
).toBeInViewport();
} );

test( 'keeps the block preview inside a short viewport', async ( {
admin,
page,
} ) => {
await page.setViewportSize( { width: 1280, height: 400 } );
await admin.createNewPost();
await page
.getByRole( 'toolbar', { name: 'Document tools' } )
.getByRole( 'button', { name: 'Block Inserter', exact: true } )
.click();
await page
.getByRole( 'region', { name: 'Block Library' } )
.getByRole( 'searchbox', { name: 'Search' } )
.fill( 'Cover' );
await page
.getByRole( 'listbox', { name: 'Blocks' } )
.getByRole( 'option', { name: 'Cover', exact: true } )
.hover();

// The popover grows to its final height once the preview has been
// measured, so wait for that before checking containment.
await expect(
page.locator(
'.block-editor-inserter__preview-content .block-editor-block-preview__content'
)
).toBeVisible();

await expect(
page.locator( '.block-editor-inserter__preview-container__popover' )
).toBeInViewport( { ratio: 1 } );
} );

[ 'large', 'small' ].forEach( ( viewport ) => {
test( `last-inserted block should be given and keep the selection (${ viewport } viewport)`, async ( {
admin,
Expand Down
Loading