Skip to content

Commit

Permalink
[3362] Ignore edge during multi-selection to apply distribution tools
Browse files Browse the repository at this point in the history
Bug: #3362
Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
  • Loading branch information
frouene authored and AxelRICHARD committed Apr 11, 2024
1 parent 10997e5 commit db3959e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ They still support returning an `java.time.Instant` object directly.
- https://github.com/eclipse-sirius/sirius-web/issues/3342[#3342] [deck] Update deck and gantt view metamodel and deck view examples
- https://github.com/eclipse-sirius/sirius-web/issues/3346[#3346] [workbench] Make the _Explorer_ panel wider by default.
- https://github.com/eclipse-sirius/sirius-web/issues/3313[#3313] [core] Avoid sending events for no-op updates of domain objects
- https://github.com/eclipse-sirius/sirius-web/issues/3362[#3362] [diagram] Ignore edge during multi-selection to apply distribution tools on nodes


== v2024.3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import ViewModuleIcon from '@material-ui/icons/ViewModule';
import ViewStreamIcon from '@material-ui/icons/ViewStream';
import VisibilityOffIcon from '@material-ui/icons/VisibilityOff';
import { memo, useCallback, useRef, useState } from 'react';
import { Edge, Node, OnSelectionChangeFunc, useOnSelectionChange, useReactFlow } from 'reactflow';
import { Node, OnSelectionChangeFunc, useOnSelectionChange, useReactFlow } from 'reactflow';
import { AlignHorizontalCenterIcon } from '../../../icons/AlignHorizontalCenterIcon';
import { AlignHorizontalLeftIcon } from '../../../icons/AlignHorizontalLeftIcon';
import { AlignHorizontalRightIcon } from '../../../icons/AlignHorizontalRightIcon';
Expand Down Expand Up @@ -85,8 +85,7 @@ const usePaletteStyle = makeStyles((theme) => ({

const isListData = (node: Node): node is Node<ListNodeData> => node.type === 'listNode';

const isSelectionContainingEdge = (selectedEdges: Edge[]) => selectedEdges.length > 0;
const canSelectedNodesBeDistributed = (selectedNodes: Node[]) => selectedNodes.length < 2;
const canSelectedNodesBeDistributed = (selectedNodes: Node[]) => selectedNodes.length > 1;

export const GroupPalette = memo(
({ refreshEventPayloadId, x, y, isOpened, refElementId, hidePalette }: GroupPaletteProps) => {
Expand Down Expand Up @@ -128,11 +127,9 @@ export const GroupPalette = memo(
});
const selectedEdges = edges.filter((edge) => edge.selected);

const isMinimalPalette =
isSelectionContainingEdge(selectedEdges) || canSelectedNodesBeDistributed(selectedListChildFiltered);
const isMinimalPalette = !canSelectedNodesBeDistributed(selectedListChildFiltered);

const computeSelectedNodes = isMinimalPalette ? selectedNodes : selectedListChildFiltered;
const selectedElements = [...computeSelectedNodes, ...selectedEdges];
const selectedElements = isMinimalPalette ? [...selectedNodes, ...selectedEdges] : [...selectedListChildFiltered];
if (selectedElements.length > 1) {
setState((prevState) => ({
...prevState,
Expand Down

0 comments on commit db3959e

Please sign in to comment.