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

[2571] Make sure edges are drawn up to the border of their target node #2578

Merged
merged 1 commit into from
Nov 15, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Note that double-clicking no longer triggers a direct edit.
- https://github.com/eclipse-sirius/sirius-web/issues/2550[#2550] [diagram] Palette is now hidden on viewport or zoom change.
- https://github.com/eclipse-sirius/sirius-web/issues/2562[#2562] [diagram] Prevent a node to be created on the TOP header of its parent.
The node will be created below the header.
- https://github.com/eclipse-sirius/sirius-web/issues/2571[#2562] [diagram] Fix a bug where edges would stop at the new creation handles instead of the border of their target node

=== New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@

import { useTheme } from '@material-ui/core/styles';
import { useContext } from 'react';
import { Connection, OnConnect, OnConnectEnd, OnConnectStart, OnConnectStartParams } from 'reactflow';
import {
Connection,
OnConnect,
OnConnectEnd,
OnConnectStart,
OnConnectStartParams,
useUpdateNodeInternals,
} from 'reactflow';
import { useDiagramElementPalette } from '../palette/useDiagramElementPalette';
import { ConnectorContext } from './ConnectorContext';
import { ConnectorContextValue } from './ConnectorContext.types';
Expand All @@ -33,6 +40,7 @@ export const useConnector = (): UseConnectorValue => {

const theme = useTheme();
const { hideDiagramElementPalette } = useDiagramElementPalette();
const updateNodeInternals = useUpdateNodeInternals();

const newConnectionStyleProvider: NodeStyleProvider = {
getNodeStyle: (id: string): React.CSSProperties => {
Expand Down Expand Up @@ -63,10 +71,13 @@ export const useConnector = (): UseConnectorValue => {

const onConnectStart: OnConnectStart = (
_event: React.MouseEvent | React.TouchEvent,
_params: OnConnectStartParams
params: OnConnectStartParams
) => {
hideDiagramElementPalette();
resetConnection();
if (params.nodeId) {
updateNodeInternals(params.nodeId);
}
};

const onConnectorContextualMenuClose = () => resetConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const getNodeCenter: GetNodeCenter = (node) => {

const getHandleCoordinatesByPosition: GetHandleCoordinatesByPosition = (node, handlePosition) => {
const handle: HandleElement | undefined = (node[internalsSymbol]?.handleBounds?.source ?? []).find(
(handle) => handle.position === handlePosition
(handle) => handle.position === handlePosition && !handle.id?.startsWith('creationhandle')
);

if (handle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ConnectionCreationHandles = ({ nodeId }: ConnectionCreationHandlesP
? Object.values(Position).map((position) => {
return (
<Handle
id={`handle--${nodeId}--${position}`}
id={`creationhandle--${nodeId}--${position}`}
type="source"
position={position}
style={connectionCreationHandleStyle(position, theme, state.isHovered, state.isMouseDown)}
Expand Down