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

Render popup menu in .djs-container #728

Merged
merged 3 commits into from
Jan 5, 2023
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
2 changes: 0 additions & 2 deletions assets/diagram-js.css
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,6 @@ marker.djs-dragger tspan {
z-index: 200;
line-height: 1;
font-family: "IBM Plex Sans", sans-serif;
border: solid 1px var(--popup-border-color);
border-radius: 2px;
}

.djs-popup {
Expand Down
9 changes: 3 additions & 6 deletions lib/features/popup-menu/PopupMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,10 @@ PopupMenu.prototype._onClosed = function() {

PopupMenu.prototype._createContainer = function(config) {

let parent = config && config.parent || 'body';
var canvas = this._canvas,
parent = canvas.getContainer();

if (typeof parent === 'string') {
parent = document.querySelector(parent);
}

const container = domify(`<div class="djs-popup-parent djs-parent" data-popup=${config.provider}></div>`);
const container = domify(`<div class="djs-popup-parent" data-popup=${config.provider}></div>`);

parent.appendChild(container);

Expand Down
16 changes: 14 additions & 2 deletions test/spec/features/popup-menu/PopupMenuSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('features/popup-menu', function() {

describe('bootstrap', function() {

it('overlay to be defined', inject(function(popupMenu) {
it('should expose <popupMenu> service', inject(function(popupMenu) {
expect(popupMenu).to.exist;
expect(popupMenu.open).to.exist;
}));
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('features/popup-menu', function() {
}));


it('should attach popup to html', inject(function(popupMenu) {
it('should scaffold basic structure', inject(function(popupMenu, canvas) {

// when
popupMenu.open({}, 'menu', { x: 100, y: 100 });
Expand All @@ -271,6 +271,18 @@ describe('features/popup-menu', function() {
}));


it('should attach to diagram container', inject(function(popupMenu, canvas) {

// when
popupMenu.open({}, 'menu', { x: 100, y: 100 });

var container = getPopupContainer();

// then
expect(container.parentNode).to.equal(canvas.getContainer());
}));


it('should be visible even if no `position.cursor` was passed', inject(function(popupMenu) {

// when
Expand Down