Skip to content

Commit

Permalink
use lodash get to avoid loads of presence checks
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Feb 4, 2020
1 parent 623a7f2 commit ec596e0
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { filter, findIndex, flow, groupBy, isEmpty, map, sortBy, without, includes } from 'lodash';
import { filter, findIndex, flow, get, groupBy, isEmpty, map, sortBy, without, includes } from 'lodash';
import scrollIntoView from 'dom-scroll-into-view';
import classnames from 'classnames';

Expand Down Expand Up @@ -251,12 +251,7 @@ export class InserterMenu extends Component {
! isEmpty( itemsPerCollection );
const hoveredItemBlockType = hoveredItem ? getBlockType( hoveredItem.name ) : null;
const hasHelpPanel = hasItems && showInserterHelpPanel;
const viewportWidth =
hoveredItemBlockType &&
hoveredItemBlockType.example &&
hoveredItemBlockType.example.viewportWidth
? hoveredItemBlockType.example.viewportWidth
: 500;
const viewportWidth = get( hoveredItemBlockType, 'example.viewportWidth', 500);

// Disable reason (no-autofocus): The inserter menu is a modal display, not one which
// is always visible, and one which already incurs this behavior of autoFocus via
Expand Down

0 comments on commit ec596e0

Please sign in to comment.