Skip to content

Commit

Permalink
[RNMobile] Fix for vertical alignment in column that is added from th…
Browse files Browse the repository at this point in the history
…e inserter menu (#24656)
  • Loading branch information
dratwas committed Aug 19, 2020
1 parent 133f0e4 commit 25bfb8e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/block-library/src/column/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { View } from 'react-native';
*/
import { withSelect } from '@wordpress/data';
import { compose, withPreferredColorScheme } from '@wordpress/compose';
import { useEffect } from '@wordpress/element';
import {
InnerBlocks,
BlockControls,
Expand Down Expand Up @@ -38,13 +39,20 @@ function ColumnEdit( {
columns,
columnCount,
selectedColumnIndex,
parentAlignment,
} ) {
const { verticalAlignment } = attributes;

const updateAlignment = ( alignment ) => {
setAttributes( { verticalAlignment: alignment } );
};

useEffect( () => {
if ( ! verticalAlignment && parentAlignment ) {
updateAlignment( parentAlignment );
}
}, [] );

const onWidthChange = ( width ) => {
setAttributes( {
width,
Expand Down Expand Up @@ -146,6 +154,7 @@ export default compose( [
getSelectedBlockClientId,
getBlocks,
getBlockOrder,
getBlockAttributes,
} = select( 'core/block-editor' );

const selectedBlockClientId = getSelectedBlockClientId();
Expand All @@ -162,13 +171,17 @@ export default compose( [
const columnCount = getBlockCount( parentId );
const columns = getBlocks( parentId );

const parentAlignment = getBlockAttributes( parentId )
?.verticalAlignment;

return {
hasChildren,
isParentSelected,
isSelected,
selectedColumnIndex,
columns,
columnCount,
parentAlignment,
};
} ),
withPreferredColorScheme,
Expand Down

0 comments on commit 25bfb8e

Please sign in to comment.