From 1a12bb22cf36cab3a4291de3f5905056e68ec3ed Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 5 Oct 2017 18:08:19 -0400 Subject: [PATCH 1/2] Writing Flow: Remove unused zones instance property --- editor/writing-flow/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/writing-flow/index.js b/editor/writing-flow/index.js index e3e09a0d24c05b..3ca0f7f560e4a9 100644 --- a/editor/writing-flow/index.js +++ b/editor/writing-flow/index.js @@ -17,7 +17,7 @@ const { UP, DOWN, LEFT, RIGHT } = keycodes; class WritingFlow extends Component { constructor() { super( ...arguments ); - this.zones = []; + this.onKeyDown = this.onKeyDown.bind( this ); this.onKeyUp = this.onKeyUp.bind( this ); this.bindContainer = this.bindContainer.bind( this ); From 757c8451773616ce4e6f1c1663b7690e306fefb9 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Thu, 5 Oct 2017 18:09:58 -0400 Subject: [PATCH 2/2] Writing Flow: Avoid using state for tracking arrow move --- editor/writing-flow/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/editor/writing-flow/index.js b/editor/writing-flow/index.js index 3ca0f7f560e4a9..fd9b5080760576 100644 --- a/editor/writing-flow/index.js +++ b/editor/writing-flow/index.js @@ -21,9 +21,8 @@ class WritingFlow extends Component { this.onKeyDown = this.onKeyDown.bind( this ); this.onKeyUp = this.onKeyUp.bind( this ); this.bindContainer = this.bindContainer.bind( this ); - this.state = { - shouldMove: false, - }; + + this.shouldMove = false; } bindContainer( ref ) { @@ -65,17 +64,18 @@ class WritingFlow extends Component { if ( ( moveUp || moveDown ) && isEdge( target, moveUp ) ) { event.preventDefault(); - this.setState( { shouldMove: true } ); + this.shouldMove = true; } } onKeyUp( event ) { const { keyCode, target } = event; const moveUp = ( keyCode === UP || keyCode === LEFT ); - if ( this.state.shouldMove ) { + + if ( this.shouldMove ) { event.preventDefault(); this.moveFocusInContainer( target, moveUp ? 'UP' : 'DOWN' ); - this.setState( { shouldMove: false } ); + this.shouldMove = false; } }