Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slot: use layout effect and update Cover block unit tests #68176

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 5 additions & 7 deletions packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ describe( 'Cover block', () => {

await selectBlock( 'Block: Cover' );
expect(
screen.getByRole( 'heading', {
name: 'Settings',
} )
await screen.findByRole( 'heading', { name: 'Settings' } )
).toBeInTheDocument();
} );
} );
Expand All @@ -216,7 +214,7 @@ describe( 'Cover block', () => {
);
await selectBlock( 'Block: Cover' );
await userEvent.click(
screen.getByLabelText( 'Fixed background' )
await screen.findByLabelText( 'Fixed background' )
);
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
'has-parallax'
Expand All @@ -232,7 +230,7 @@ describe( 'Cover block', () => {
);
await selectBlock( 'Block: Cover' );
await userEvent.click(
screen.getByLabelText( 'Repeated background' )
await screen.findByLabelText( 'Repeated background' )
);
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
'is-repeated'
Expand All @@ -245,7 +243,7 @@ describe( 'Cover block', () => {
} );

await selectBlock( 'Block: Cover' );
await userEvent.clear( screen.getByLabelText( 'Left' ) );
await userEvent.clear( await screen.findByLabelText( 'Left' ) );
await userEvent.type( screen.getByLabelText( 'Left' ), '100' );

expect(
Expand All @@ -262,7 +260,7 @@ describe( 'Cover block', () => {

await selectBlock( 'Block: Cover' );
await userEvent.type(
screen.getByLabelText( 'Alternative text' ),
await screen.findByLabelText( 'Alternative text' ),
'Me'
);
expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

- `SlotFill`: rewrite the non-portal version to use `observableMap` ([#67400](https://github.com/WordPress/gutenberg/pull/67400)).
- `DatePicker`: Prepare day buttons for 40px default size ([#68156](https://github.com/WordPress/gutenberg/pull/68156)).
- `SlotFill`: register slots in a layout effect ([#68176](https://github.com/WordPress/gutenberg/pull/68176)).

## 29.0.0 (2024-12-11)

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/slot-fill/slot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ReactElement, ReactNode, Key } from 'react';
import { useObservableValue } from '@wordpress/compose';
import {
useContext,
useEffect,
useLayoutEffect,
useRef,
Children,
cloneElement,
Expand Down Expand Up @@ -54,7 +54,7 @@ function Slot( props: Omit< SlotComponentProps, 'bubblesVirtually' > ) {

const { name, children, fillProps = {} } = props;

useEffect( () => {
useLayoutEffect( () => {
const instance = instanceRef.current;
registry.registerSlot( name, instance );
return () => registry.unregisterSlot( name, instance );
Expand Down
Loading