mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-18 10:31:08 +00:00
Avoid enter editing if there is another active object on the canvas (#5261)
* better-than-nothing * check that the active object exist * test * added a test
This commit is contained in:
parent
5c3f3a9594
commit
68a84a7da7
3 changed files with 25 additions and 1 deletions
|
|
@ -620,7 +620,7 @@
|
|||
}
|
||||
this._handleEvent(e, 'down');
|
||||
// we must renderAll so that we update the visuals
|
||||
shouldRender && this.requestRenderAll();
|
||||
(shouldRender || shouldGroup) && this.requestRenderAll();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -139,6 +139,16 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.canvas) {
|
||||
var currentActive = this.canvas._activeObject;
|
||||
if (currentActive && currentActive !== this) {
|
||||
// avoid running this logic when there is an active object
|
||||
// this because is possible with shift click and fast clicks,
|
||||
// to rapidly deselect and reselect this object and trigger an enterEdit
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.__lastSelected && !this.__corner) {
|
||||
this.selected = false;
|
||||
this.__lastSelected = false;
|
||||
|
|
|
|||
|
|
@ -61,12 +61,26 @@
|
|||
iText.renderCursorOrSelection = function() {};
|
||||
assert.equal(iText.isEditing, false, 'iText not editing');
|
||||
iText.canvas = canvas;
|
||||
canvas._activeObject = null;
|
||||
iText.selected = true;
|
||||
iText.__lastSelected = true;
|
||||
iText.mouseUpHandler({ e: {} });
|
||||
assert.equal(iText.isEditing, true, 'iText entered editing');
|
||||
iText.exitEditing();
|
||||
});
|
||||
QUnit.test('_mouseUpHandler on a selected object does enter edit if there is an activeObject', function(assert) {
|
||||
var iText = new fabric.IText('test');
|
||||
iText.initDelayedCursor = function() {};
|
||||
iText.renderCursorOrSelection = function() {};
|
||||
assert.equal(iText.isEditing, false, 'iText not editing');
|
||||
iText.canvas = canvas;
|
||||
canvas._activeObject = new fabric.IText('test2');
|
||||
iText.selected = true;
|
||||
iText.__lastSelected = true;
|
||||
iText.mouseUpHandler({ e: {} });
|
||||
assert.equal(iText.isEditing, false, 'iText did not enter editing');
|
||||
iText.exitEditing();
|
||||
});
|
||||
QUnit.test('_mouseUpHandler on a selected text in a group DOES NOT enter edit', function(assert) {
|
||||
var iText = new fabric.IText('test');
|
||||
iText.initDelayedCursor = function() {};
|
||||
|
|
|
|||
Loading…
Reference in a new issue