Skip to content

Commit

Permalink
WritingFlow must listen to global events
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Oct 31, 2017
1 parent cf075fb commit 1efd3cc
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions editor/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class WritingFlow extends Component {
this.verticalRect = null;
}

componentDidMount() {
document.addEventListener( 'keydown', this.onKeyDown );
document.addEventListener( 'mousedown', this.clearVerticalRect );
}

componentWillUnmount() {
document.removeEventListener( 'keydown', this.onKeyDown );
document.addEventListener( 'mousedown', this.clearVerticalRect );
}

bindContainer( ref ) {
this.container = ref;
}
Expand Down Expand Up @@ -156,19 +166,11 @@ class WritingFlow extends Component {
render() {
const { children } = this.props;

// Disable reason: Wrapper itself is non-interactive, but must capture
// bubbling events from children to determine focus transition intents.
/* eslint-disable jsx-a11y/no-static-element-interactions */
return (
<div
ref={ this.bindContainer }
onKeyDown={ this.onKeyDown }
onMouseDown={ this.clearVerticalRect }
>
<div ref={ this.bindContainer }>
{ children }
</div>
);
/* eslint-disable jsx-a11y/no-static-element-interactions */
}
}

Expand Down

0 comments on commit 1efd3cc

Please sign in to comment.