mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-19 16:55:02 +02:00
Fix canvas context menu selection
This commit is contained in:
parent
614cfe2f7c
commit
ce2dfd4c57
|
|
@ -1507,6 +1507,25 @@ describe('Canvas', () => {
|
|||
useContextMenu().close();
|
||||
});
|
||||
|
||||
it('clears the node selection when opening the pane context menu', async () => {
|
||||
const node = createCanvasNodeElement({ id: 'node-1', label: 'Node 1' });
|
||||
workflowDocumentStore.setNodes([createTestNode({ id: node.id, name: 'Node 1' })]);
|
||||
|
||||
const { container } = renderComponent({
|
||||
props: { nodes: [node] },
|
||||
});
|
||||
await waitFor(() => expect(container.querySelectorAll('.vue-flow__node')).toHaveLength(1));
|
||||
|
||||
const { addSelectedNodes, findNode, getSelectedNodes } = useVueFlow(canvasId);
|
||||
addSelectedNodes([findNode(node.id)!]);
|
||||
await waitFor(() => expect(getSelectedNodes.value).toHaveLength(1));
|
||||
|
||||
await fireEvent.contextMenu(container.querySelector('.vue-flow__pane')!);
|
||||
|
||||
await waitFor(() => expect(getSelectedNodes.value).toHaveLength(0));
|
||||
expect(useContextMenu().targetNodeIds.value).toEqual([]);
|
||||
});
|
||||
|
||||
async function renderWithGroup(
|
||||
props: { readOnly?: boolean; suppressInteraction?: boolean } = {},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1407,6 +1407,15 @@ function onOpenContextMenu(
|
|||
});
|
||||
}
|
||||
|
||||
function onOpenPaneContextMenu(event: MouseEvent) {
|
||||
clearSelectedNodes();
|
||||
contextMenu.open(event, {
|
||||
source: 'canvas',
|
||||
nodeIds: [],
|
||||
readOnly: isContextMenuReadOnly.value,
|
||||
});
|
||||
}
|
||||
|
||||
function onOpenSelectionContextMenu({ event }: { event: MouseEvent }) {
|
||||
onOpenContextMenu(event);
|
||||
}
|
||||
|
|
@ -1797,7 +1806,7 @@ defineExpose({
|
|||
@connect="onConnect"
|
||||
@connect-end="onConnectEnd"
|
||||
@pane-click="onClickPane"
|
||||
@pane-context-menu="onOpenContextMenu"
|
||||
@pane-context-menu="onOpenPaneContextMenu"
|
||||
@move="onPaneMove"
|
||||
@move-end="onPaneMoveEnd"
|
||||
@node-drag-start="onNodeDragStart"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user