Skip to content

Commit

Permalink
fix selection clearing (#3538)
Browse files Browse the repository at this point in the history
  • Loading branch information
asturur committed Dec 28, 2016
1 parent 582cd4d commit a99ea40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/mixins/canvas_events.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@
_shouldRender: function(target, pointer) {
var activeObject = this.getActiveGroup() || this.getActiveObject();

if (activeObject && activeObject.isEditing) {
// if we mouse up/down over a editing textbox a cursor change,
// there is no need to re render
return false;
}
return !!(
(target && (
target.isMoving ||
Expand Down
9 changes: 8 additions & 1 deletion src/mixins/itext_key_behavior.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot
}
e.stopImmediatePropagation();
e.preventDefault();
this.canvas && this.canvas.renderAll();
if (e.keyCode >= 33 && e.keyCode <= 40) {
// if i press an arrow key just update selection
this.clearContextTop();
this.renderCursorOrSelection();
}
else {
this.canvas && this.canvas.renderAll();
}
},

/**
Expand Down
8 changes: 4 additions & 4 deletions src/shapes/itext.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@
render: function(ctx, noTransform) {
this.clearContextTop();
this.callSuper('render', ctx, noTransform);
// clear the cursorOffsetCache, so we ensure to calculate once per renderCursor
// the correct position but not at every cursor animation.
this.cursorOffsetCache = { };
this.renderCursorOrSelection();
},

/**
Expand All @@ -338,10 +342,6 @@
_render: function(ctx) {
this.callSuper('_render', ctx);
this.ctx = ctx;
// clear the cursorOffsetCache, so we ensure to calculate once per renderCursor
// the correct position but not at every cursor animation.
this.cursorOffsetCache = { };
this.renderCursorOrSelection();
},

/**
Expand Down

0 comments on commit a99ea40

Please sign in to comment.