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

Remove the BlockAsyncRenderProvider and render parents asynchronously #19343

Merged
merged 2 commits into from
Jan 6, 2020
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

This file was deleted.

9 changes: 2 additions & 7 deletions packages/block-editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { AsyncModeProvider, useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import BlockAsyncModeProvider from './block-async-mode-provider';
import BlockListBlock from './block';
import BlockListAppender from '../block-list-appender';
import __experimentalBlockListFooter from '../block-list-footer';
Expand Down Expand Up @@ -88,11 +87,7 @@ function BlockList( {
selectedBlockClientId === clientId;

return (
<BlockAsyncModeProvider
key={ 'block-' + clientId }
clientId={ clientId }
isBlockInSelection={ isBlockInSelection }
>
<AsyncModeProvider key={ clientId } value={ ! isBlockInSelection }>
<BlockListBlock
rootClientId={ rootClientId }
clientId={ clientId }
Expand All @@ -106,7 +101,7 @@ function BlockList( {
animateOnChange={ index }
enableAnimation={ enableAnimation }
/>
</BlockAsyncModeProvider>
</AsyncModeProvider>
);
} ) }
<BlockListAppender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
const INSERTER_RESULTS_SELECTOR = '.block-editor-inserter__results';
const QUOTE_INSERT_BUTTON_SELECTOR = '//button[.="Quote"]';
const APPENDER_SELECTOR = '.my-custom-awesome-appender';
const DYNAMIC_APPENDER_SELECTOR = '.my-dynamic-blocks-appender';
const DYNAMIC_APPENDER_SELECTOR = 'my-dynamic-blocks-appender';

describe( 'RenderAppender prop of InnerBlocks ', () => {
beforeAll( async () => {
Expand Down Expand Up @@ -69,17 +69,15 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
await insertBlock( 'InnerBlocks renderAppender dynamic' );

// Wait for the custom dynamic block appender to appear.
await page.waitForSelector( DYNAMIC_APPENDER_SELECTOR );
await page.waitForSelector( '.' + DYNAMIC_APPENDER_SELECTOR );

// Verify if the custom block appender text is the expected one.
expect(
await page.evaluate(
( el ) => ( el.innerText ),
await page.$( `${ DYNAMIC_APPENDER_SELECTOR } > span.empty-blocks-appender` ) )
).toEqual( 'Empty Blocks Appender' );
await page.waitForXPath(
`//*[contains(@class, "${ DYNAMIC_APPENDER_SELECTOR }")]/span[contains(@class, "empty-blocks-appender")][contains(text(), "Empty Blocks Appender")]`
);

// Open the inserter of our custom block appender and expand all the categories.
const blockAppenderButtonSelector = `${ DYNAMIC_APPENDER_SELECTOR } .block-editor-button-block-appender`;
const blockAppenderButtonSelector = `.${ DYNAMIC_APPENDER_SELECTOR } .block-editor-button-block-appender`;
await page.click( blockAppenderButtonSelector );
await openAllBlockInserterCategories();

Expand All @@ -99,11 +97,9 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
await quoteButton.click();

// Verify if the custom block appender text changed as expected.
expect(
await page.evaluate(
( el ) => ( el.innerText ),
await page.$( `${ DYNAMIC_APPENDER_SELECTOR } > span.single-blocks-appender` ) )
).toEqual( 'Single Blocks Appender' );
await page.waitForXPath(
`//*[contains(@class, "${ DYNAMIC_APPENDER_SELECTOR }")]/span[contains(@class, "single-blocks-appender")][contains(text(), "Single Blocks Appender")]`
);

// Verify that the custom appender button is still being rendered.
expect(
Expand All @@ -114,11 +110,9 @@ describe( 'RenderAppender prop of InnerBlocks ', () => {
await insertBlock( 'Video' );

// Verify if the custom block appender text changed as expected.
expect(
await page.evaluate(
( el ) => ( el.innerText ),
await page.$( `${ DYNAMIC_APPENDER_SELECTOR } > span.multiple-blocks-appender` ) )
).toEqual( 'Multiple Blocks Appender' );
await page.waitForXPath(
`//*[contains(@class, "${ DYNAMIC_APPENDER_SELECTOR }")]/span[contains(@class, "multiple-blocks-appender")][contains(text(), "Multiple Blocks Appender")]`
);

// Verify that the custom appender button is now not being rendered.
expect(
Expand Down