Skip to content

Commit

Permalink
[1304] Wrong element dropped in an unsynchronized diagram
Browse files Browse the repository at this point in the history
Bug : eclipse-sirius#1304
Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
  • Loading branch information
AxelRICHARD committed Apr 20, 2023
1 parent 5c54b7f commit df1ca3e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.adoc
@@ -1,6 +1,23 @@
= Changelog

== v2023.4.0 (unreleased)
== 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 an unsynchronized diagram took the selected element instead of the dragged one.

=== New Features

=== Improvements


== v2023.4.0

=== Architectural decision records

Expand Down
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

0 comments on commit df1ca3e

Please sign in to comment.