Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WritingFlow: Avoid function instantiation in render #3153

Merged
merged 1 commit into from
Oct 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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