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

[1304] Wrong element dropped in an unsynchronized diagram #1901

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
= Changelog

== v2023.6.0 (unreleased)

=== Architectural decision records

=== Breaking changes

=== Dependency update

=== Bug fixes

- https://github.com/eclipse-sirius/sirius-components/issues/1304[#1304] [tree] Fix an issue where dropping an element from the tree to a diagram used the current selection instead of the dragged tree item.

=== New Features

=== Improvements


== v2023.4.0

=== Architectural decision records
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* Obeo - initial API and implementation
*******************************************************************************/
import { gql, useMutation } from '@apollo/client';
import { DRAG_SOURCES_TYPE, Selection, ServerContext } from '@eclipse-sirius/sirius-components-core';
import { DRAG_SOURCES_TYPE, Selection, SelectionEntry, ServerContext } from '@eclipse-sirius/sirius-components-core';
import IconButton from '@material-ui/core/IconButton';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import { makeStyles } from '@material-ui/core/styles';
import CropDinIcon from '@material-ui/icons/CropDin';
import MoreVertIcon from '@material-ui/icons/MoreVert';
import React, { useContext, useEffect, useRef, useState } from 'react';
Expand Down Expand Up @@ -376,8 +376,14 @@ export const TreeItem = ({
const draggable = kind.startsWith('siriusComponents://semantic');
const dragStart: React.DragEventHandler<HTMLDivElement> = (event) => {
const entries = selection.entries.filter((entry) => entry.kind.startsWith('siriusComponents://semantic'));

if (entries.length > 0) {
event.dataTransfer.setData(DRAG_SOURCES_TYPE, JSON.stringify(entries));
if (!selection.entries.map((entry) => entry.id).includes(item.id)) {
const itemEntry: SelectionEntry = { id: item.id, label: item.label, kind: item.kind };
event.dataTransfer.setData(DRAG_SOURCES_TYPE, JSON.stringify([itemEntry]));
} else {
event.dataTransfer.setData(DRAG_SOURCES_TYPE, JSON.stringify(entries));
}
}
};
const dragOver: React.DragEventHandler<HTMLDivElement> = (event) => {
Expand Down