Skip to content

Commit

Permalink
Remove the BlockAsyncRenderProvider and render parents asynchronously (
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored Jan 6, 2020
1 parent 7a0e48c commit 6bf89a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 45 deletions.

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 @@ -95,11 +94,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 @@ -115,7 +110,7 @@ function BlockList( {
hasSelectedUI={ uiParts.hasSelectedUI }
hasMovers={ uiParts.hasMovers }
/>
</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

0 comments on commit 6bf89a4

Please sign in to comment.