Skip to content

Commit

Permalink
Inserter: Try making the inline tokens less important (#8587)
Browse files Browse the repository at this point in the history
* Inserter: Try making the inline tokens less important

* Move the inline elements after the most used blocks

* Fix inline tokens test
  • Loading branch information
youknowriad committed Aug 6, 2018
1 parent 576872f commit c59ca24
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export class InserterMenu extends Component {
role="region"
aria-label={ __( 'Available block types' ) }
>
<InserterResultsPortal.Slot fillProps={ { filterValue } } />

<ChildBlocks
rootClientId={ rootClientId }
Expand All @@ -231,6 +230,9 @@ export class InserterMenu extends Component {
<BlockTypesList items={ suggestedItems } onSelect={ onSelect } onHover={ this.onHover } />
</PanelBody>
}

<InserterResultsPortal.Slot fillProps={ { filterValue } } />

{ map( getCategories(), ( category ) => {
const categoryItems = itemsPerCategory[ category.slug ];
if ( ! categoryItems || ! categoryItems.length ) {
Expand All @@ -248,6 +250,7 @@ export class InserterMenu extends Component {
</PanelBody>
);
} ) }

{ !! reusableItems.length && (
<PanelBody
title={ __( 'Reusable' ) }
Expand Down
4 changes: 3 additions & 1 deletion packages/editor/src/components/inserter/results-portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { searchItems } from './menu';

const { Fill, Slot } = createSlotFill( 'InserterResultsPortal' );

const InserterResultsPortal = ( { items, title, onSelect, onHover } ) => {
const InserterResultsPortal = ( { items, title, onSelect, onHover, ...props } ) => {
return (
<Fill>
{ ( { filterValue } ) => {
Expand All @@ -24,6 +24,8 @@ const InserterResultsPortal = ( { items, title, onSelect, onHover } ) => {
return (
<PanelBody
title={ title }
{ ...props }
className="editor-inserter__results-portal"
>
<BlockTypesList items={ filteredItems } onSelect={ onSelect } onHover={ onHover } />
</PanelBody>
Expand Down
9 changes: 4 additions & 5 deletions packages/editor/src/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ $block-inserter-search-height: 38px;
}
}

.editor-inserter__results-portal {
margin-top: -1px;
}

.editor-inserter__menu.is-bottom:after {
border-bottom-color: $white;
}
Expand Down Expand Up @@ -101,11 +105,6 @@ $block-inserter-search-height: 38px;
[role="presentation"] + .components-panel__body {
border-top: none;
}

// Don't show the bottom border on the last panel, let the library itself show the border.
.components-panel__body:last-child {
border-bottom: none;
}
}

.editor-inserter__popover .editor-block-types-list {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class TokenUI extends Component {
items={ this.props.items }
onSelect={ this.onSelect }
onHover={ this.onHover }
initialOpen={ false }
/>
{ hovered &&
<div
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/adding-inline-tokens.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe( 'adding inline tokens', () => {
await page.click( '.editor-default-block-appender' );
await page.keyboard.type( 'a ' );

await insertBlock( 'Inline Image' );
await insertBlock( 'Inline Image', 'Inline Elements' );

// Wait for media modal to appear and upload image.
await page.waitForSelector( '.media-modal input[type=file]' );
Expand Down
7 changes: 6 additions & 1 deletion test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ export async function searchForBlock( searchTerm ) {
* result that appears.
*
* @param {string} searchTerm The text to search the inserter for.
* @param {string} panelName The inserter panel to open (if it's closed by default).
*/
export async function insertBlock( searchTerm ) {
export async function insertBlock( searchTerm, panelName = null ) {
await searchForBlock( searchTerm );
if ( panelName ) {
const panelButton = ( await page.$x( `//button[contains(text(), '${ panelName }')]` ) )[ 0 ];
await panelButton.click();
}
await page.click( `button[aria-label="${ searchTerm }"]` );
}

Expand Down

0 comments on commit c59ca24

Please sign in to comment.