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

Fix Inserter on the widgets screen #24045

Merged
merged 1 commit into from
Jul 20, 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
1 change: 1 addition & 0 deletions packages/block-editor/src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class Inserter extends Component {
/>
);
}

return (
<InserterMenu
onSelect={ onClose }
Expand Down
4 changes: 1 addition & 3 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ function InserterMenu( {
</div>
</div>
{ showInserterHelpPanel && hoveredItem && (
<div className="block-editor-inserter__preview-container">
<InserterPreviewPanel item={ hoveredItem } />
</div>
<InserterPreviewPanel item={ hoveredItem } />
) }
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import BlockPreview from '../block-preview';
function InserterPreviewPanel( { item } ) {
const hoveredItemBlockType = getBlockType( item.name );
return (
<div className="block-editor-inserter__menu-preview-panel">
<div className="block-editor-inserter__preview-container">
<div className="block-editor-inserter__preview">
{ isReusableBlock( item ) || hoveredItemBlockType.example ? (
<div className="block-editor-inserter__preview-content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const searchBlockItems = (
* @param {Object} config Search Config.
* @return {Array} Filtered item list.
*/
export const searchItems = ( items, searchTerm, config = {} ) => {
export const searchItems = ( items = [], searchTerm = '', config = {} ) => {
const normalizedSearchTerms = normalizeSearchTerm( searchTerm );
if ( normalizedSearchTerms.length === 0 ) {
return items;
Expand Down
8 changes: 4 additions & 4 deletions packages/block-editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ $block-inserter-tabs-height: 44px;
.block-editor-inserter__popover .block-editor-inserter__menu {
margin: -$grid-unit-15;

.block-editor-inserter__search {
top: -$grid-unit-15;
}

.block-editor-inserter__tabs .components-tab-panel__tabs {
top: $grid-unit-10 + $grid-unit-20 + $grid-unit-60 - $grid-unit-15;
}
Expand All @@ -31,6 +27,10 @@ $block-inserter-tabs-height: 44px;
overflow: visible;
height: auto;
}

.block-editor-inserter__preview-container {
display: none;
}
}

.block-editor-inserter__toggle.components-button {
Expand Down
9 changes: 9 additions & 0 deletions packages/edit-widgets/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@wordpress/block-editor';
import { PinnedItems } from '@wordpress/interface';
import { useViewportMatch } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -22,6 +23,13 @@ const inserterToggleProps = { isPrimary: true };

function Header( { isCustomizer } ) {
const isLargeViewport = useViewportMatch( 'medium' );
const rootClientId = useSelect( ( select ) => {
const { getBlockRootClientId, getBlockSelectionEnd } = select(
'core/block-editor'
);
return getBlockRootClientId( getBlockSelectionEnd() );
}, [] );

return (
<>
<div className="edit-widgets-header">
Expand All @@ -30,6 +38,7 @@ function Header( { isCustomizer } ) {
position="bottom right"
showInserterHelpPanel
toggleProps={ inserterToggleProps }
rootClientId={ rootClientId }
/>
<UndoButton />
<RedoButton />
Expand Down