Skip to content

Commit

Permalink
Use a list for the block types list.
Browse files Browse the repository at this point in the history
  • Loading branch information
afercia authored and youknowriad committed Jun 4, 2018
1 parent 22308dc commit ad79082
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 30 deletions.
65 changes: 36 additions & 29 deletions editor/components/inserter/item-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,47 @@ class ItemList extends Component {
const { items, onSelect, onHover } = this.props;

return (
<div className="editor-inserter__item-list">
/*
* Disable reason: The `list` ARIA role is redundant but
* Safari+VoiceOver won't announce the list otherwise.
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
<ul role="list" className="editor-inserter__list">
{ items.map( ( item ) => {
return (
<button
key={ item.id }
className={
classnames(
'editor-inserter__item',
getBlockMenuDefaultClassName( item.id ),
{
'editor-inserter__item-has-children': item.hasChildBlocks,
}
)
}
onClick={ () => onSelect( item ) }
disabled={ item.isDisabled }
onMouseEnter={ () => onHover( item ) }
onMouseLeave={ () => onHover( null ) }
onFocus={ () => onHover( item ) }
onBlur={ () => onHover( null ) }
aria-label={ item.title } // Fix for IE11 and JAWS 2018.
>
<span className="editor-inserter__item-icon">
<BlockIcon icon={ item.icon } />
{ item.hasChildBlocks && <span className="editor-inserter__item-icon-stack" /> }
</span>
<li className="editor-inserter__list-item" key={ item.id }>
<button
className={
classnames(
'editor-inserter__item',
getBlockMenuDefaultClassName( item.id ),
{
'editor-inserter__item-has-children': item.hasChildBlocks,
}
)
}
onClick={ () => onSelect( item ) }
disabled={ item.isDisabled }
onMouseEnter={ () => onHover( item ) }
onMouseLeave={ () => onHover( null ) }
onFocus={ () => onHover( item ) }
onBlur={ () => onHover( null ) }
aria-label={ item.title } // Fix for IE11 and JAWS 2018.
>
<span className="editor-inserter__item-icon">
<BlockIcon icon={ item.icon } />
{ item.hasChildBlocks && <span className="editor-inserter__item-icon-stack" /> }
</span>

<span className="editor-inserter__item-title">
{ item.title }
</span>
</button>
<span className="editor-inserter__item-title">
{ item.title }
</span>
</button>
</li>
);
} ) }
</div>
</ul>
/* eslint-enable jsx-a11y/no-redundant-roles */
);
}
}
Expand Down
8 changes: 7 additions & 1 deletion editor/components/inserter/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ $block-inserter-search-height: 38px;
}
}

.editor-inserter__item-list {
.editor-inserter__list {
list-style: none;
margin: 0 -8px;
padding: 0;
}

.editor-inserter__list-item {
display: inline;
}

.editor-inserter__item {
Expand Down

0 comments on commit ad79082

Please sign in to comment.