diff --git a/src/mixins/itext_key_behavior.mixin.js b/src/mixins/itext_key_behavior.mixin.js index fdc907ad82e..68d9371794b 100644 --- a/src/mixins/itext_key_behavior.mixin.js +++ b/src/mixins/itext_key_behavior.mixin.js @@ -501,7 +501,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot if (this.selectionStart === 0 && this.selectionEnd === 0) { return; } - var changed = true; + var changed = false; if (e.shiftKey) { if (this._selectionDirection === 'right' && this.selectionStart !== this.selectionEnd) { changed = this._moveLeft(e, 'selectionEnd'); @@ -512,8 +512,8 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot } } else { + changed = true; this._selectionDirection = 'left'; - // only move cursor when there is no selection, // otherwise we discard it, and leave cursor on same place if (this.selectionEnd === this.selectionStart && this.selectionStart !== 0) { @@ -532,7 +532,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot if (this.selectionStart >= this._text.length && this.selectionEnd >= this._text.length) { return; } - var changed = true; + var changed = false; if (e.shiftKey) { if (this._selectionDirection === 'left' && this.selectionStart !== this.selectionEnd) { changed = this._moveRight(e, 'selectionStart'); @@ -543,6 +543,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot } } else { + changed = true; this._selectionDirection = 'right'; if (this.selectionStart === this.selectionEnd) { changed = this._moveRight(e, 'selectionStart'); diff --git a/test/unit/itext_key_behaviour.js b/test/unit/itext_key_behaviour.js index 3671b7b4a16..785696abd2b 100644 --- a/test/unit/itext_key_behaviour.js +++ b/test/unit/itext_key_behaviour.js @@ -40,16 +40,16 @@ iText.selectionStart = 2; iText.selectionEnd = 2; - iText.moveCursorLeft({ shiftKey: false}); - assert.equal(selection, 1, 'should fire once on moveCursorLeft'); + iText.moveCursorStartDir({ shiftKey: false}); + assert.equal(selection, 1, 'should fire once on moveCursorStartDir'); assert.equal(iText.selectionStart, 1, 'should be 1 less than 2'); assert.equal(iText.selectionEnd, 1, 'should be 1 less than 2'); selection = 0; iText.selectionStart = 2; iText.selectionEnd = 2; - iText.moveCursorRight({ shiftKey: false}); - assert.equal(selection, 1, 'should fire once on moveCursorRight'); + iText.moveCursorEndDir({ shiftKey: false}); + assert.equal(selection, 1, 'should fire once on moveCursorEndDir'); assert.equal(iText.selectionStart, 3, 'should be 1 more than 2'); assert.equal(iText.selectionEnd, 3, 'should be 1 more than 2'); selection = 0; @@ -80,7 +80,7 @@ iText.selectionStart = 0; iText.selectionEnd = 0; - iText.moveCursorLeft({ shiftKey: false}); + iText.moveCursorStartDir({ shiftKey: false}); assert.equal(selection, 0, 'should not fire with no change'); assert.equal(iText.selectionStart, 0, 'should not move'); assert.equal(iText.selectionEnd, 0, 'should not move'); @@ -92,7 +92,7 @@ iText.selectionStart = 31; iText.selectionEnd = 31; - iText.moveCursorRight({ shiftKey: false}); + iText.moveCursorEndDir({ shiftKey: false}); assert.equal(selection, 0, 'should not fire with no change'); assert.equal(iText.selectionStart, 31, 'should not move'); assert.equal(iText.selectionEnd, 31, 'should not move'); @@ -120,7 +120,7 @@ iText.selectionStart = 28; iText.selectionEnd = 31; - iText.moveCursorLeft({ shiftKey: false }); + iText.moveCursorStartDir({ shiftKey: false }); assert.equal(selection, 1, 'should fire'); assert.equal(iText.selectionStart, 28, 'should move to selection Start'); assert.equal(iText.selectionEnd, 28, 'should move to selection Start'); @@ -174,16 +174,16 @@ iText.selectionStart = 2; iText.selectionEnd = 2; - iText.moveCursorLeft({ shiftKey: false}); - assert.equal(selection, 1, 'should fire once on moveCursorLeft'); + iText.moveCursorStartDir({ shiftKey: false}); + assert.equal(selection, 1, 'should fire once on moveCursorStartDir'); assert.equal(iText.selectionStart, 1, 'should be 1 less than 2'); assert.equal(iText.selectionEnd, 1, 'should be 1 less than 2'); selection = 0; iText.selectionStart = 2; iText.selectionEnd = 2; - iText.moveCursorRight({ shiftKey: false}); - assert.equal(selection, 1, 'should fire once on moveCursorRight'); + iText.moveCursorEndDir({ shiftKey: false}); + assert.equal(selection, 1, 'should fire once on moveCursorEndDir'); assert.equal(iText.selectionStart, 3, 'should be 1 more than 2'); assert.equal(iText.selectionEnd, 3, 'should be 1 more than 2'); selection = 0; @@ -215,7 +215,7 @@ iText.selectionStart = 0; iText.selectionEnd = 1; iText._selectionDirection = 'left'; - iText.moveCursorLeft({ shiftKey: true}); + iText.moveCursorStartDir({ shiftKey: true}); assert.equal(selection, 0, 'should not fire with no change'); assert.equal(iText.selectionStart, 0, 'should not move'); assert.equal(iText.selectionEnd, 1, 'should not move'); @@ -229,7 +229,7 @@ iText.selectionStart = 30; iText.selectionEnd = 31; iText._selectionDirection = 'right'; - iText.moveCursorRight({ shiftKey: true}); + iText.moveCursorEndDir({ shiftKey: true}); assert.equal(selection, 0, 'should not fire with no change'); assert.equal(iText.selectionStart, 30, 'should not move'); assert.equal(iText.selectionEnd, 31, 'should not move'); diff --git a/test/unit/text.js b/test/unit/text.js index 8df477ff256..35fb395a9c9 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -43,7 +43,7 @@ underline: false, overline: false, linethrough: false, - textAlign: 'left', + textAlign: 'start', textBackgroundColor: '', fillRule: 'nonzero', paintFirst: 'fill', @@ -56,7 +56,7 @@ strokeUniform: false, direction: 'ltr', pathStartOffset: 0, - pathSide: 'left', + pathSide: 'start', pathAlign: 'baseline' }; diff --git a/test/unit/textbox.js b/test/unit/textbox.js index 90f8ff75461..4c3a2009d92 100644 --- a/test/unit/textbox.js +++ b/test/unit/textbox.js @@ -40,7 +40,7 @@ underline: false, overline: false, linethrough: false, - textAlign: 'left', + textAlign: 'start', backgroundColor: '', textBackgroundColor: '', fillRule: 'nonzero', @@ -56,7 +56,7 @@ path: null, direction: 'ltr', pathStartOffset: 0, - pathSide: 'left', + pathSide: 'start', pathAlign: 'baseline' };