Skip to content

Commit

Permalink
Fix empty secondary sidebar overlapping widget editor content on mobi…
Browse files Browse the repository at this point in the history
…le viewports (#38017)

* Fix empty secondary sidebar overlapping widget editor content on mobile viewports

* Add e2e test
  • Loading branch information
talldan authored Jan 17, 2022
1 parent 5c3f884 commit 0ffa10e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 36 additions & 0 deletions packages/e2e-tests/specs/widgets/editing-widgets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
openGlobalBlockInserter,
searchForBlock,
closeGlobalBlockInserter,
setBrowserViewport,
} from '@wordpress/e2e-test-utils';

/**
Expand Down Expand Up @@ -842,6 +843,41 @@ describe( 'Widgets screen', () => {
expect( listItems.length >= widgetAreas.length ).toEqual( true );
await closeListView();
} );

// Check for regressions of https://github.com/WordPress/gutenberg/issues/38002.
it( 'allows blocks to be added on mobile viewports', async () => {
await setBrowserViewport( 'small' );
const [ firstWidgetArea ] = await findAll( {
role: 'document',
name: 'Block: Widget Area',
} );

const addParagraphBlock = await getBlockInGlobalInserter( 'Paragraph' );
await addParagraphBlock.click();

const addedParagraphBlockInFirstWidgetArea = await find(
{
name: /^Empty block/,
selector: '[data-block][data-type="core/paragraph"]',
},
{
root: firstWidgetArea,
}
);
await addedParagraphBlockInFirstWidgetArea.focus();
await page.keyboard.type( 'First Paragraph' );
const updatedParagraphBlockInFirstWidgetArea = await find(
{
name: 'Paragraph block',
value: 'First Paragraph',
},
{
root: firstWidgetArea,
}
);

expect( updatedParagraphBlockInFirstWidgetArea ).toBeTruthy();
} );
} );

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/edit-widgets/src/components/layout/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ function Interface( { blockEditorSettings } ) {
}
}, [ isInserterOpened, isListViewOpened, isHugeViewport ] );

const hasSecondarySidebar = isListViewOpened || isInserterOpened;

return (
<InterfaceSkeleton
labels={ interfaceLabels }
header={ <Header /> }
secondarySidebar={ <SecondarySidebar /> }
secondarySidebar={ hasSecondarySidebar && <SecondarySidebar /> }
sidebar={
hasSidebarEnabled && (
<ComplementaryArea.Slot scope="core/edit-widgets" />
Expand Down

0 comments on commit 0ffa10e

Please sign in to comment.