Skip to content

Commit 1888ee9

Browse files
committed
Apply order by Flexbox order property
1 parent 8e20050 commit 1888ee9

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

editor/modes/visual-editor/block.js

+11-3
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
* WordPress dependencies
@@ -186,7 +186,14 @@ class VisualEditorBlock extends wp.element.Component {
186186
'is-hovered': isHovered,
187187
} );
188188

189-
const { onSelect, onHover, onMouseLeave, onFocus, onInsertAfter } = this.props;
189+
const {
190+
onSelect,
191+
onHover,
192+
onMouseLeave,
193+
onFocus,
194+
onInsertAfter,
195+
order,
196+
} = this.props;
190197

191198
// Determine whether the block has props to apply to the wrapper
192199
let wrapperProps;
@@ -209,8 +216,9 @@ class VisualEditorBlock extends wp.element.Component {
209216
onMouseLeave={ onMouseLeave }
210217
className={ className }
211218
data-type={ block.blockType }
212-
tabIndex="0"
219+
tabIndex={ order }
213220
{ ...wrapperProps }
221+
style={ { ...get( wrapperProps, 'style' ), order } }
214222
>
215223
{ ( ( isSelected && ! isTyping ) || isHovered ) && <BlockMover uid={ block.uid } /> }
216224
{ isSelected && ! isTyping &&

editor/modes/visual-editor/index.js

+7-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,20 +11,21 @@ import './style.scss';
1011
import Inserter from '../../inserter';
1112
import VisualEditorBlock from './block';
1213
import PostTitle from '../../post-title';
13-
import { getBlockUids } from '../../selectors';
1414

1515
function VisualEditor( { blocks } ) {
1616
return (
1717
<div className="editor-visual-editor">
1818
<PostTitle />
19-
{ blocks.map( ( uid ) => (
20-
<VisualEditorBlock key={ uid } uid={ uid } />
21-
) ) }
19+
<div className="editor-visual-editor__blocks">
20+
{ map( blocks, ( block, uid ) => (
21+
<VisualEditorBlock key={ uid } uid={ uid } />
22+
) ) }
23+
</div>
2224
<Inserter />
2325
</div>
2426
);
2527
}
2628

2729
export default connect( ( state ) => ( {
28-
blocks: getBlockUids( state ),
30+
blocks: state.editor.blocksByUid,
2931
} ) )( VisualEditor );

editor/modes/visual-editor/style.scss

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
margin-right: auto;
2626
}
2727

28+
.editor-visual-editor__blocks {
29+
display: flex;
30+
flex-direction: column;
31+
}
32+
2833
.editor-visual-editor__block {
2934
position: relative;
3035
left: -#{ $block-padding + $block-mover-margin }; /* Make room for the mover */

0 commit comments

Comments
 (0)