diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c513c7ff5..8719f8724 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -90,6 +90,7 @@ It is now possible to reference an element in any of the containing namespaces o The drop doesn't reveal the _documentation_ compartment anymore, and a warning message is displayed to indicate that the drop is not possible. - https://github.com/eclipse-syson/syson/issues/711[#711] [diagrams] Prevent feature typing from disappearing when nesting a PartUsage in a PartDefinition. * The tool _Add Part as nested Part_ now correctly keeps the existing relationships of the PartUsage after its owner is changed. +- https://github.com/eclipse-syson/syson/issues/722[#722] [diagrams] Allow the drop of the root element of a diagram on its background. === Improvements diff --git a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java index 6796ac808..26a606964 100644 --- a/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java +++ b/backend/views/syson-diagram-common-view/src/main/java/org/eclipse/syson/diagram/common/view/services/ViewToolService.java @@ -346,9 +346,9 @@ public Element dropElementFromExplorer(Element element, IEditingContext editingC optTargetElement = this.objectService.getObject(editingContext, diagramContext.getDiagram().getTargetObjectId()); } if (optTargetElement.isPresent() && optTargetElement.get() instanceof Element targetElement) { - // Check if the element we attempt to drop is in the ancestors of the target element. If it is the case we - // want to prevent the drop. - if (EMFUtils.isAncestor(element, targetElement)) { + // Check if the element we attempt to drop is in the ancestors of the target element and we attempt to drop + // it on anything else than the diagram background. If it is the case we want to prevent the drop. + if (EMFUtils.isAncestor(element, targetElement) && selectedNode != null) { final String errorMessage; if (element == targetElement) { errorMessage = MessageFormat.format("Cannot drop {0} on itself", element.getName()); diff --git a/doc/content/modules/user-manual/pages/release-notes/2024.9.0.adoc b/doc/content/modules/user-manual/pages/release-notes/2024.9.0.adoc index 3c2a08ab7..a46492161 100644 --- a/doc/content/modules/user-manual/pages/release-notes/2024.9.0.adoc +++ b/doc/content/modules/user-manual/pages/release-notes/2024.9.0.adoc @@ -110,6 +110,7 @@ It is now possible to reference an element in any of the containing namespaces o The drop isn't allowed anymore, and a warning message is displayed. - Fix an issue that deleted feature typing specialization when nesting a PartUsage in a PartDefinition. * The tool _Add Part as nested Part_ now correctly keeps the existing relationships of the PartUsage after its owner is changed. +- Fix an issue that prevented the drop of the root element of a diagram on its background. == Improvements diff --git a/integration-tests/cypress/e2e/project/diagrams/general-view/dropFromExplorer.cy.ts b/integration-tests/cypress/e2e/project/diagrams/general-view/dropFromExplorer.cy.ts index f736613da..dd5260eb0 100644 --- a/integration-tests/cypress/e2e/project/diagrams/general-view/dropFromExplorer.cy.ts +++ b/integration-tests/cypress/e2e/project/diagrams/general-view/dropFromExplorer.cy.ts @@ -59,6 +59,14 @@ describe('Drop From Explorer Tests', () => { .should('exist'); }); + it.only('Then we can drop the Package on the diagram', () => { + const dataTransfer = new DataTransfer(); + explorer.dragTreeItem(sysmlv2.getRootElementLabel(), dataTransfer); + diagram.dropOnDiagram(diagramLabel, dataTransfer); + + diagram.getNodes(diagramLabel, sysmlv2.getRootElementLabel()).should('exist'); + }); + it('Then we can drop the PartUsage on the diagram, and its compartment are not visible', () => { const dataTransfer = new DataTransfer(); explorer.dragTreeItem('part', dataTransfer);