Do not fire selection changed if we are not editing (#3702)

* Do not fire selection changed if we are not editing
* fire selection changed event after enter editing
* fix tests

* fixed trailing space
This commit is contained in:
Andrea Bogazzi 2017-02-16 16:16:43 -05:00 committed by GitHub
parent c9e50febad
commit 085a3c75fc
3 changed files with 9 additions and 5 deletions

View file

@ -355,7 +355,7 @@
this._tick();
this.fire('editing:entered');
this._fireSelectionChanged();
if (!this.canvas) {
return this;
}

View file

@ -153,8 +153,10 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
this.selectionStart = newSelection;
this.selectionEnd = newSelection;
}
this._fireSelectionChanged();
this._updateTextarea();
if (this.isEditing) {
this._fireSelectionChanged();
this._updateTextarea();
}
},
/**

View file

@ -13,7 +13,8 @@
iText.on('selection:changed', countSelectionChange);
iText.enterEditing();
equal(selection, 0, 'should not fire on enter edit');
equal(selection, 1, 'will fire on enter edit since the cursor is changing for the first time');
selection = 0;
iText.selectAll();
equal(selection, 1, 'should fire once on selectAll');
@ -144,7 +145,8 @@
iText.on('selection:changed', countSelectionChange);
iText.enterEditing();
equal(selection, 0, 'should not fire on enter edit');
equal(selection, 1, 'should fire on enter edit');
selection = 0;
iText.selectAll();
equal(selection, 1, 'should fire once on selectAll');