Skip to content

Commit 1150c76

Browse files
committed
Apply order by Flexbox order property
1 parent 43f3efb commit 1150c76

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

editor/modes/visual-editor/block.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { connect } from 'react-redux';
55
import classnames from 'classnames';
66
import { Slot } from 'react-slot-fill';
7-
import { partial } from 'lodash';
7+
import { partial, get } from 'lodash';
88

99
/**
1010
* Internal dependencies
@@ -130,7 +130,15 @@ class VisualEditorBlock extends wp.element.Component {
130130
'is-hovered': isHovered
131131
} );
132132

133-
const { onSelect, onStartTyping, onHover, onMouseLeave, onFocus, onInsertAfter } = this.props;
133+
const {
134+
onSelect,
135+
onStartTyping,
136+
onHover,
137+
onMouseLeave,
138+
onFocus,
139+
onInsertAfter,
140+
order
141+
} = this.props;
134142

135143
// Determine whether the block has props to apply to the wrapper
136144
let wrapperProps;
@@ -155,6 +163,7 @@ class VisualEditorBlock extends wp.element.Component {
155163
className={ className }
156164
data-type={ block.blockType }
157165
{ ...wrapperProps }
166+
style={ { ...get( wrapperProps, 'style' ), order } }
158167
>
159168
{ ( ( isSelected && ! isTyping ) || isHovered ) && <BlockMover uid={ block.uid } /> }
160169
{ isSelected && ! isTyping &&

editor/modes/visual-editor/index.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* External dependencies
33
*/
44
import { connect } from 'react-redux';
5+
import { map } from 'lodash';
56

67
/**
78
* Internal dependencies
@@ -10,17 +11,23 @@ import './style.scss';
1011
import Inserter from 'components/inserter';
1112
import VisualEditorBlock from './block';
1213

13-
function VisualEditor( { blocks } ) {
14+
function VisualEditor( { blocks, blockOrder } ) {
1415
return (
1516
<div className="editor-visual-editor">
16-
{ blocks.map( ( uid ) => (
17-
<VisualEditorBlock key={ uid } uid={ uid } />
18-
) ) }
17+
<div className="editor-visual-editor__blocks">
18+
{ map( blocks, ( block, uid ) => (
19+
<VisualEditorBlock
20+
key={ uid }
21+
uid={ uid }
22+
order={ blockOrder.indexOf( uid ) } />
23+
) ) }
24+
</div>
1925
<Inserter />
2026
</div>
2127
);
2228
}
2329

2430
export default connect( ( state ) => ( {
25-
blocks: state.blocks.order
31+
blocks: state.blocks.byUid,
32+
blockOrder: state.blocks.order
2633
} ) )( VisualEditor );

editor/modes/visual-editor/style.scss

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
}
1111
}
1212

13+
.editor-visual-editor__blocks {
14+
display: flex;
15+
flex-direction: column;
16+
}
17+
1318
.editor-visual-editor__block {
1419
position: relative;
1520
border: 2px solid transparent;

0 commit comments

Comments
 (0)