From e5ba308b65a1b46a0547d1bcfff575850cfd732a Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 27 Apr 2017 13:49:37 +0100 Subject: [PATCH] Simplify the toolbar computing --- editor/modes/visual-editor/block.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index f2cee2da3e8295..ad334a7184d3ad 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -4,7 +4,6 @@ import { connect } from 'react-redux'; import classnames from 'classnames'; import { Slot } from 'react-slot-fill'; -import { reduce, last } from 'lodash'; /** * Internal dependencies @@ -139,15 +138,9 @@ class VisualEditorBlock extends wp.element.Component { } // Normalize controls as an array of arrays (toolbars of controls) - const toolbars = reduce( settings.controls, ( result, toolbar ) => ( - Array.isArray( toolbar ) - // Array entry is simply concatenated into normalized value - // Example: [ [ 1, 2 ], [ 3, 4 ] ] => [ [ 1, 2 ], [ 3, 4 ] ] - ? [ ...result, toolbar ] - // Singular values are appended to the last array in the result - // Example: [ 1, 2, 3, 4 ] => [ [ 1, 2, 3, 4 ] ] - : [ ...result.slice( 0, -1 ), [ ...( last( result ) || [] ), toolbar ] ] - ), [] ); + const toolbars = settings.controls && settings.controls.length && ! Array.isArray( settings.controls[ 0 ] ) + ? [ settings.controls ] + : settings.controls; // Disable reason: Each block can receive focus but must be able to contain // block children. Tab keyboard navigation enabled by tabIndex assignment.