Skip to content

Commit

Permalink
Update const getBlockWidth to get the width from `div.editor-block-…
Browse files Browse the repository at this point in the history
…list__block-edit`
  • Loading branch information
azaozz committed Nov 24, 2018
1 parent 652ac92 commit 078a75b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/editor/src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ export const getBlockWidth = ( () => {
return;
}

const block = document.createElement( 'div' );
const measure = document.createElement( 'div' );
measure.className = 'wp-block editor-block-list__block';
layout.appendChild( measure );
const { clientWidth } = measure;
layout.removeChild( measure );

// 30 = ( 2 * $block-padding ) + ( 2 * $border-width )
// See: https://github.com/WordPress/gutenberg/blob/master/assets/stylesheets/_variables.scss
width = clientWidth - 30;
block.className = 'wp-block editor-block-list__block';
measure.className = 'editor-block-list__block-edit';
layout.appendChild( block );
block.appendChild( measure );

width = measure.clientWidth;
layout.removeChild( block );
}

return width;
Expand Down

0 comments on commit 078a75b

Please sign in to comment.