Skip to content

Commit

Permalink
Checking for object. Now passing complete object to box control.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Jan 25, 2022
1 parent 2b71f0d commit 5a9bbcb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/block-editor/src/hooks/gap.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ export function GapEdit( props ) {
}

const onChange = ( next ) => {
const row = next?.top ?? next;
const column = next?.left ?? next;
const newValue = row === column ? row : `${ row } ${ column }`;

let newValue = next;
if ( typeof next === 'object' ) {
const row = next?.top;
const column = next?.left;
newValue = row === column ? row : `${ row } ${ column }`;
}
const newStyle = {
...style,
spacing: {
Expand Down Expand Up @@ -145,16 +147,22 @@ export function GapEdit( props ) {
const boxValues = {
left: undefined,
top: undefined,
bottom: undefined,
right: undefined,
};

if ( boxValuesArray.length === 1 ) {
boxValues.left = boxValuesArray[ 0 ];
boxValues.right = boxValuesArray[ 0 ];
boxValues.top = boxValuesArray[ 0 ];
boxValues.bottom = boxValuesArray[ 0 ];
}

if ( boxValuesArray.length === 2 ) {
boxValues.left = boxValuesArray[ 1 ];
boxValues.right = boxValuesArray[ 1 ];
boxValues.top = boxValuesArray[ 0 ];
boxValues.bottom = boxValuesArray[ 0 ];
}

// The default combined value we'll take from row.
Expand Down

0 comments on commit 5a9bbcb

Please sign in to comment.