Skip to content

Commit

Permalink
[1304] Ensure that the proper element is dropped from the explorer
Browse files Browse the repository at this point in the history
Bug : #1304
Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
  • Loading branch information
AxelRICHARD authored and sbegaudeau committed Apr 28, 2023
1 parent d2b73e1 commit 3fb9800
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
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

0 comments on commit 3fb9800

Please sign in to comment.