Skip to content

Commit

Permalink
fix(editor): Fix position of connector buttons when the line is strai…
Browse files Browse the repository at this point in the history
…ght (#13034)
  • Loading branch information
autologie authored Feb 4, 2025
1 parent 884a7e2 commit 3a908ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,9 @@ describe('CanvasEdge', () => {
},
});

const label = container.querySelector('.vue-flow__edge-label');
const label = container.querySelector('.vue-flow__edge-label')?.childNodes[0];

expect(label).toHaveAttribute(
'style',
'transform: translate(-50%, -150%) translate(50px, 50px);',
);
expect(label).toHaveAttribute('style', 'transform: translate(0, -100%);');
});

it("should render a label in the middle of the connector when it isn't straight", () => {
Expand All @@ -202,11 +199,8 @@ describe('CanvasEdge', () => {
},
});

const label = container.querySelector('.vue-flow__edge-label');
const label = container.querySelector('.vue-flow__edge-label')?.childNodes[0];

expect(label).toHaveAttribute(
'style',
'transform: translate(-50%, -50%) translate(50px, 50px);',
);
expect(label).toHaveAttribute('style', 'transform: translate(0, 0%);');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,16 @@ const edgeClasses = computed(() => ({
}));
const edgeLabelStyle = computed(() => ({
transform: `translate(0, ${isConnectorStraight.value ? '-100%' : '0%'})`,
color: edgeColor.value,
}));
const isConnectorStraight = computed(() => renderData.value.isConnectorStraight);
const edgeToolbarStyle = computed(() => {
const translateY = isConnectorStraight.value ? '-150%' : '-50%';
return {
transform: `translate(-50%, ${translateY}) translate(${labelPosition.value[0]}px, ${labelPosition.value[1]}px)`,
...(props.hovered ? { zIndex: 1 } : {}),
};
});
const edgeToolbarStyle = computed(() => ({
transform: `translate(-50%, -50%) translate(${labelPosition.value[0]}px, ${labelPosition.value[1]}px)`,
...(props.hovered ? { zIndex: 1 } : {}),
}));
const edgeToolbarClasses = computed(() => ({
[$style.edgeLabelWrapper]: true,
Expand Down

0 comments on commit 3a908ac

Please sign in to comment.