From e7dce9190a9681134f953c2b2abcfa0096643fe1 Mon Sep 17 00:00:00 2001 From: Zachary Vance Date: Wed, 27 May 2015 18:45:46 -0700 Subject: [PATCH] Pressing down on the last node should move the cursor to the end --- dist/flowy.js | 9 +++++++-- dist/flowy.unwrapped.js | 9 +++++++-- src/views/todo.js | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dist/flowy.js b/dist/flowy.js index 8c72528..547ad42 100644 --- a/dist/flowy.js +++ b/dist/flowy.js @@ -475,8 +475,12 @@ var TodoView = Backbone.View.extend({ return false; }, focusNext: function() { + if (!this.duringEditing()) return true; var nextNode = this.model.nextNode({ childrenAllowed: true }); - if (!nextNode) return false; + if (!nextNode) { // If it's the last node, move the cursor to the end of the node by allowing the default action. + return true; + } + this.stopEditingText(); nextNode.getView().startEditingText(); return false; @@ -604,8 +608,9 @@ var TodoView = Backbone.View.extend({ }, moveDown: function() { this._maintainingFocus(_.bind(function() { - this.model.moveDown(); + return this.model.moveDown(); }, this)); + return false; }, moveUp: function() { diff --git a/dist/flowy.unwrapped.js b/dist/flowy.unwrapped.js index 1e19a38..c168b12 100644 --- a/dist/flowy.unwrapped.js +++ b/dist/flowy.unwrapped.js @@ -474,8 +474,12 @@ var TodoView = Backbone.View.extend({ return false; }, focusNext: function() { + if (!this.duringEditing()) return true; var nextNode = this.model.nextNode({ childrenAllowed: true }); - if (!nextNode) return false; + if (!nextNode) { // If it's the last node, move the cursor to the end of the node by allowing the default action. + return true; + } + this.stopEditingText(); nextNode.getView().startEditingText(); return false; @@ -603,8 +607,9 @@ var TodoView = Backbone.View.extend({ }, moveDown: function() { this._maintainingFocus(_.bind(function() { - this.model.moveDown(); + return this.model.moveDown(); }, this)); + return false; }, moveUp: function() { diff --git a/src/views/todo.js b/src/views/todo.js index 05d49fa..1a774b8 100644 --- a/src/views/todo.js +++ b/src/views/todo.js @@ -78,8 +78,12 @@ var TodoView = Backbone.View.extend({ return false; }, focusNext: function() { + if (!this.duringEditing()) return true; var nextNode = this.model.nextNode({ childrenAllowed: true }); - if (!nextNode) return false; + if (!nextNode) { // If it's the last node, move the cursor to the end of the node by allowing the default action. + return true; + } + this.stopEditingText(); nextNode.getView().startEditingText(); return false; @@ -207,8 +211,9 @@ var TodoView = Backbone.View.extend({ }, moveDown: function() { this._maintainingFocus(_.bind(function() { - this.model.moveDown(); + return this.model.moveDown(); }, this)); + return false; }, moveUp: function() { -- 2.47.3