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(controls) ISSUE-6201 Restore per object setting of controls visibility #6226

Merged
merged 4 commits into from
Mar 22, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
added test
asturur committed Mar 21, 2020
commit 7c32e9d65c0f7c63b1f092c4ee7ce8a46aed051e
12 changes: 0 additions & 12 deletions src/mixins/object_interactivity.mixin.js
Original file line number Diff line number Diff line change
@@ -329,18 +329,6 @@
return this;
},

/**
* Returns the instance of the control visibility set for this object.
* @private
* @returns {Object}
*/
_getControlsVisibility: function() {
var visibility = {};
this.forEachControl(function(control, key, fabricObject) {
visibility[key] = control.getVisibility(fabricObject, key);
});
return visibility;
},

/**
* This callback function is called every time _discardActiveObject or _setActiveObject
17 changes: 17 additions & 0 deletions test/unit/object_interactivity.js
Original file line number Diff line number Diff line change
@@ -32,6 +32,23 @@
assert.equal(cObj.isControlVisible('tl'), true);
});

QUnit.test('setControlVisible is per object', function(assert) {
assert.ok(fabric.Object);

var cObj = new fabric.Object({ });
var cObj2 = new fabric.Object({ });

cObj.setControlVisible('tl', false);
assert.equal(cObj.isControlVisible('tl'), false, 'setting to false worked for cObj');
assert.equal(cObj2.isControlVisible('tl'), true, 'setting to false did not work for cObj2');
cObj.controls.tl.setVisibility(false);
assert.equal(cObj2.isControlVisible('tl'), false, 'setting directly on controls works for every object');
cObj.setControlVisible('tl', true);
assert.equal(cObj.isControlVisible('tl'), true, 'object setting takes precendence');
// restore original visibility
cObj.controls.tl.setVisibility(true);
});

QUnit.test('setControlsVisibility', function(assert) {
assert.ok(fabric.Object);