Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fabric.Canvas): ISSUE-6314 rerender in case of single drag selection #6421

Merged
merged 3 commits into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/mixins/canvas_events.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,14 @@
shouldRender = transform.actionPerformed;
}
if (!isClick) {
var targetWasActive = target === this._activeObject;
this._maybeGroupObjects(e);
shouldRender || (shouldRender = this._shouldRender(target));
if (!shouldRender) {
shouldRender = (
this._shouldRender(target) ||
(!targetWasActive && target === this._activeObject)
);
}
}
if (target) {
var corner = target._findTargetCorner(
Expand Down
22 changes: 22 additions & 0 deletions test/unit/canvas_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,28 @@
canvas.__onMouseUp(e4);
});

QUnit.test('specific bug #6314 for partial intersection with drag', function(assert) {
var canvas = this.canvas = new fabric.Canvas(null, {enableRetinaScaling: false, width: 600, height: 600});
var renderRequested = false;
var greenRect = new fabric.Rect({
width: 300,
height: 300,
left: 50,
top: 0,
fill: 'green',
});
canvas.add(greenRect);
canvas._onMouseDown({ clientX: 25, clientY: 25, which: 1, target: canvas.upperCanvasEl });
canvas._onMouseMove({ clientX: 30, clientY: 30, which: 1, target: canvas.upperCanvasEl });
canvas._onMouseMove({ clientX: 100, clientY: 50, which: 1, target: canvas.upperCanvasEl });
canvas.requestRenderAll = function() {
renderRequested = true;
};
canvas._onMouseUp({ clientX: 100, clientY: 50, which: 1, target: canvas.upperCanvasEl });
assert.equal(renderRequested, true, 'a render has been requested');
});


QUnit.test('mouse:up isClick = true', function(assert) {
var e = { clientX: 30, clientY: 30, which: 1, target: canvas.upperCanvasEl };
var isClick = false;
Expand Down