Skip to content

Commit

Permalink
fix(): text enterEditing in interactive group
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Apr 10, 2022
1 parent 3e09114 commit af3430c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mixins/itext_click_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
mouseUpHandler: function(options) {
this.__isMousedown = false;
if (!this.editable ||
(this.group && !this.group.interactive) ||
(options.transform && options.transform.actionPerformed) ||
(options.e.button && options.e.button !== 1)) {
return;
Expand Down
9 changes: 7 additions & 2 deletions test/unit/itext_click_behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,23 @@
assert.equal(iText.isEditing, false, 'iText should not enter editing');
iText.exitEditing();
});
QUnit.test('_mouseUpHandler on a text in a group does enter editing', function (assert) {
QUnit.test('_mouseUpHandler on a text in a group', function (assert) {
var iText = new fabric.IText('test');
iText.initDelayedCursor = function () { };
iText.renderCursorOrSelection = function () { };
assert.equal(iText.isEditing, false, 'iText not editing');
var group = new fabric.Group([iText], { subTargetCheck: true });
var group = new fabric.Group([iText], { subTargetCheck: true, interactive: true });
canvas.add(group);
iText.selected = true;
iText.__lastSelected = true;
canvas.__onMouseUp({ clientX: 1, clientY: 1 });
assert.equal(iText.isEditing, true, 'iText should enter editing');
iText.exitEditing();
group.interactive = false;
iText.selected = true;
iText.__lastSelected = true;
canvas.__onMouseUp({ clientX: 1, clientY: 1 });
assert.equal(iText.isEditing, false, 'iText should not enter editing');
});
QUnit.test('_mouseUpHandler on a corner of selected text DOES NOT enter edit', function(assert) {
var iText = new fabric.IText('test');
Expand Down

0 comments on commit af3430c

Please sign in to comment.