From 3727e0f6a06b8e5736afae49e66df71a5fcbd384 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Wed, 25 Oct 2017 16:10:00 +0100 Subject: [PATCH] WritingFlow: Avoid function instantiation in `render` --- editor/writing-flow/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/editor/writing-flow/index.js b/editor/writing-flow/index.js index 01ef108b0f4fcb..ada6ce2f690a14 100644 --- a/editor/writing-flow/index.js +++ b/editor/writing-flow/index.js @@ -8,9 +8,9 @@ import { find, reverse } from 'lodash'; * Internal dependencies */ import { + computeCaretRect, isHorizontalEdge, isVerticalEdge, - computeCaretRect, placeCaretAtHorizontalEdge, placeCaretAtVerticalEdge, } from '../utils/dom'; @@ -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; } @@ -34,6 +35,10 @@ class WritingFlow extends Component { this.container = ref; } + clearVerticalRect() { + this.verticalRect = null; + } + getVisibleTabbables() { return focus.tabbable .find( this.container ) @@ -104,7 +109,7 @@ class WritingFlow extends Component {
this.verticalRect = null } + onMouseDown={ this.clearVerticalRect } > { children }