Skip to content

Commit 0ecf9e3

Browse files
committed
Removed the state in the EditorMobileNavigation component, make it rely on layoutFocus instead
1 parent 0dde5ee commit 0ecf9e3

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

client/post-editor/editor-mobile-navigation/index.jsx

+9-18
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import classnames from 'classnames';
88
* Internal dependencies
99
*/
1010
import Gridicon from 'components/gridicon';
11-
import layoutFocus from 'lib/layout-focus';
1211
import EditorPublishButton from 'post-editor/editor-publish-button';
1312
import Button from 'components/button';
13+
import observe from 'lib/mixins/data-observe';
1414

1515
export default React.createClass( {
1616
displayName: 'EditorMobileNavigation',
1717

18+
mixins: [ observe( 'layoutFocus' ) ],
19+
1820
propTypes: {
1921
site: PropTypes.object,
2022
post: PropTypes.object,
@@ -25,27 +27,16 @@ export default React.createClass( {
2527
isPublishing: PropTypes.bool,
2628
isSaveBlocked: PropTypes.bool,
2729
hasContent: PropTypes.bool,
28-
onClose: PropTypes.func
29-
},
30-
31-
getInitialState: function() {
32-
return {
33-
sidebarOpen: false
34-
};
30+
onClose: PropTypes.func,
31+
layoutFocus: PropTypes.object
3532
},
3633

3734
openSidebar: function() {
38-
if ( ! this.state.sidebarOpen ) {
39-
layoutFocus.set( 'sidebar' );
40-
this.setState( { sidebarOpen: true } );
41-
}
35+
this.props.layoutFocus.set( 'sidebar' );
4236
},
4337

4438
closeSidebar: function() {
45-
if ( this.state.sidebarOpen ) {
46-
layoutFocus.set( 'content' );
47-
this.setState( { sidebarOpen: false } );
48-
}
39+
this.props.layoutFocus.set( 'content' );
4940
},
5041

5142
render: function() {
@@ -66,14 +57,14 @@ export default React.createClass( {
6657
<Gridicon
6758
icon="pencil"
6859
className={ classnames( 'editor-mobile-navigation__icon', {
69-
'is-selected': ! this.state.sidebarOpen
60+
'is-selected': this.props.layoutFocus.getCurrent() === 'content'
7061
} ) } />
7162
</Button>
7263
<Button borderless onClick={ this.openSidebar }>
7364
<Gridicon
7465
icon="cog"
7566
className={ classnames( 'editor-mobile-navigation__icon', {
76-
'is-selected': this.state.sidebarOpen
67+
'is-selected': this.props.layoutFocus.getCurrent() === 'sidebar'
7768
} ) } />
7869
</Button>
7970
</div>

client/post-editor/post-editor.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ const PostEditor = React.createClass( {
326326
isPublishing={ this.state.isPublishing }
327327
isSaveBlocked={ this.state.isSaveBlocked }
328328
hasContent={ this.state.hasContent }
329-
onClose={ this.onClose } />
329+
onClose={ this.onClose }
330+
layoutFocus={ layoutFocus }/>
330331
<div className="post-editor__content">
331332
<div className="editor">
332333
<EditorActionBar

0 commit comments

Comments
 (0)