}
}
+ componentDidMount () {
+ this._updateFocusAndSelection({ });
+ }
+
componentDidUpdate (prevProps) {
+ this._updateFocusAndSelection(prevProps);
+ }
+
+ _updateFocusAndSelection = (prevProps) => {
// This statement does several things:
// - If we're beginning a reply, and,
// - Replying to zero or one users, places the cursor at the end of the textbox.
children: PropTypes.node,
};
+ // Corresponds to (max-width: 600px + (285px * 1) + (10px * 1)) in SCSS
+ mediaQuery = 'matchMedia' in window && window.matchMedia('(max-width: 895px)');
+
state = {
shouldAnimate: false,
+ renderComposePanel: !(this.mediaQuery && this.mediaQuery.matches),
}
componentWillReceiveProps() {
this.node.addEventListener('wheel', this.handleWheel, supportsPassiveEvents ? { passive: true } : false);
}
+ if (this.mediaQuery) {
+ this.mediaQuery.addEventListener('change', this.handleLayoutChange);
+ this.setState({ renderComposePanel: !this.mediaQuery.matches });
+ }
+
this.lastIndex = getIndex(this.context.router.history.location.pathname);
this.isRtlLayout = document.getElementsByTagName('body')[0].classList.contains('rtl');
if (!this.props.singleColumn) {
this.node.removeEventListener('wheel', this.handleWheel);
}
+
+ if (this.mediaQuery) {
+ this.mediaQuery.removeEventListener('change', this.handleLayoutChange);
+ }
}
handleChildrenContentChange() {
}
}
+ handleLayoutChange = (e) => {
+ this.setState({ renderComposePanel: !e.matches });
+ }
+
handleSwipe = (index) => {
this.pendingIndex = index;
render () {
const { columns, children, singleColumn, isModalOpen, intl } = this.props;
- const { shouldAnimate } = this.state;
+ const { shouldAnimate, renderComposePanel } = this.state;
const columnIndex = getIndex(this.context.router.history.location.pathname);
<div className='columns-area__panels'>
<div className='columns-area__panels__pane columns-area__panels__pane--compositional'>
<div className='columns-area__panels__pane__inner'>
- <ComposePanel />
+ {renderComposePanel && <ComposePanel />}
</div>
</div>