Skip to content

Commit

Permalink
Buttons: move options to constants to avoid unneeded renders (#32356)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwwar authored and youknowriad committed Jun 7, 2021
1 parent 37394d5 commit 8fca63e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions packages/block-library/src/buttons/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ import { name as buttonBlockName } from '../button';

const ALLOWED_BLOCKS = [ buttonBlockName ];
const BUTTONS_TEMPLATE = [ [ 'core/button' ] ];
const LAYOUT = {
type: 'default',
alignments: [],
};
const VERTICAL_JUSTIFY_CONTROLS = [ 'left', 'center', 'right' ];
const HORIZONTAL_JUSTIFY_CONTROLS = [
'left',
'center',
'right',
'space-between',
];

function ButtonsEdit( {
attributes: { contentJustification, orientation },
Expand All @@ -35,17 +46,14 @@ function ButtonsEdit( {
allowedBlocks: ALLOWED_BLOCKS,
template: BUTTONS_TEMPLATE,
orientation,
__experimentalLayout: {
type: 'default',
alignments: [],
},
__experimentalLayout: LAYOUT,
templateInsertUpdatesSelection: true,
} );

const justifyControls =
orientation === 'vertical'
? [ 'left', 'center', 'right' ]
: [ 'left', 'center', 'right', 'space-between' ];
? VERTICAL_JUSTIFY_CONTROLS
: HORIZONTAL_JUSTIFY_CONTROLS;

return (
<>
Expand Down

0 comments on commit 8fca63e

Please sign in to comment.