Skip to content

Commit

Permalink
WritingFlow: Avoid function instantiation in render (#3153)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf authored Oct 25, 2017
1 parent ec8df21 commit 31e5867
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions editor/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { find, reverse } from 'lodash';
* Internal dependencies
*/
import {
computeCaretRect,
isHorizontalEdge,
isVerticalEdge,
computeCaretRect,
placeCaretAtHorizontalEdge,
placeCaretAtVerticalEdge,
} from '../utils/dom';
Expand All @@ -26,6 +26,7 @@ class WritingFlow extends Component {

this.onKeyDown = this.onKeyDown.bind( this );
this.bindContainer = this.bindContainer.bind( this );
this.clearVerticalRect = this.clearVerticalRect.bind( this );

this.verticalRect = null;
}
Expand All @@ -34,6 +35,10 @@ class WritingFlow extends Component {
this.container = ref;
}

clearVerticalRect() {
this.verticalRect = null;
}

getVisibleTabbables() {
return focus.tabbable
.find( this.container )
Expand Down Expand Up @@ -104,7 +109,7 @@ class WritingFlow extends Component {
<div
ref={ this.bindContainer }
onKeyDown={ this.onKeyDown }
onMouseDown={ () => this.verticalRect = null }
onMouseDown={ this.clearVerticalRect }
>
{ children }
</div>
Expand Down

0 comments on commit 31e5867

Please sign in to comment.