fix(context-pad): fix context pad positioning in special case

context pad was misplaced when the canvas is placed with a left offset within the parent
This commit is contained in:
Mohsen Hariri 2015-05-08 14:26:05 +02:00 committed by Ricardo Matias
parent 9b88fceb28
commit 206457e764
2 changed files with 33 additions and 1 deletions

View File

@ -77,9 +77,10 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
padRect = pad.getBoundingClientRect(); padRect = pad.getBoundingClientRect();
var top = padRect.top - diagramRect.top; var top = padRect.top - diagramRect.top;
var left = padRect.left - diagramRect.left;
var pos = { var pos = {
x: padRect.left, x: left,
y: top + padRect.height + Y_OFFSET y: top + padRect.height + Y_OFFSET
}; };

View File

@ -28,4 +28,35 @@ describe('features - context-pad', function() {
})); }));
}); });
describe('should show chooser/replace menu in the correct position ', function() {
it('for a diagram element', inject(function(elementRegistry, eventBus, contextPad, popupMenu) {
// given
var text = document.createElement("SPAN");
text.innerText = "Pushing the canvas a bit to the right";
document.body.insertBefore(text, document.body.firstChild);
TestHelper.insertCSS('diagram.css', 'div[class=test-container]{display: inline-block;}');
var element = elementRegistry.get('StartEvent_1');
var replaceMenuRect;
var padMenuRect;
// when
eventBus.on('contextPad.open', function(event) {
event.current.entries.replace.action.click(null, element);
replaceMenuRect = popupMenu._instances['replace-menu']._container.getBoundingClientRect();
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
});
eventBus.fire('element.click', { element: element });
// then
expect(replaceMenuRect.left).not.
toBeGreaterThan(padMenuRect.left);
}));
});
}); });