resolve todos

This commit is contained in:
peterkogo
2025-04-16 18:20:12 +02:00
parent 2474c8be14
commit 97c4e2b218
7 changed files with 34 additions and 29 deletions

View File

@@ -61,7 +61,6 @@ export default function zoom(domNode: Element, params: ZoomParams) {
onDraggingChange
});
//TODO: is this neccessary?
const viewport = panZoomInstance.getViewport();
if (
initialViewport.x !== viewport.x ||

View File

@@ -5,8 +5,7 @@
import type { NodeProps } from '$lib/types';
let {
// TODO: do we really want this!?
data = { label: 'Node' },
data,
targetPosition = Position.Top,
sourcePosition = Position.Bottom
}: NodeProps = $props();

View File

@@ -52,7 +52,6 @@
let labelledBy = $derived(`svelte-flow__minimap-desc-${store.flowId}`);
// TODO: simplify this
let viewBB = $derived({
x: -store.viewport.x / store.viewport.zoom,
y: -store.viewport.y / store.viewport.zoom,

View File

@@ -11,6 +11,7 @@
} from '@xyflow/system';
import type { ResizeControlProps } from './types';
import { useSvelteFlow } from '$lib/hooks/useSvelteFlow.svelte';
import type { Node } from '$lib/types';
let {
nodeId,
@@ -67,20 +68,31 @@
};
},
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
updateNode(id, (node) => ({
...node,
position: { x: change.x ?? node.position.x, y: change.y ?? node.position.y },
width: change.width ?? node.width,
height: change.height ?? node.height
}));
const changes = new Map<string, Partial<Node>>();
let position = change.x && change.y ? { x: change.x, y: change.y } : undefined;
changes.set(id, { ...change, position });
// TODO: performance?
for (const childChange of childChanges) {
updateNode(childChange.id, (node) => ({
...node,
changes.set(childChange.id, {
position: childChange.position
}));
});
}
store.nodes = store.nodes.map((node) => {
const change = changes.get(node.id);
if (change) {
return {
...node,
position: {
x: change.position?.x ?? node.position.x,
y: change.position?.y ?? node.position.y
},
width: change.width ?? node.width,
height: change.height ?? node.height
};
}
return node;
});
}
});
}

View File

@@ -112,7 +112,6 @@ test.describe('Edges', () => {
await page.mouse.down();
await page.mouse.up();
// TODO: times out on webkit
await expect(edge).toHaveClass(/selected/);
await page.keyboard.press('d');
@@ -139,12 +138,10 @@ test.describe('Edges', () => {
const edgeBox = await edge.boundingBox();
//FIXME: Negative values are not working. Investigate further
await page.mouse.move(edgeBox!.x + edgeBox!.width * 0.5 + 21, edgeBox!.y + edgeBox!.height * 0.5);
await page.mouse.down();
await page.mouse.up();
// TODO: times out on webkit
await expect(edge).toHaveClass(/selected/);
});

View File

@@ -145,7 +145,6 @@ test.describe('Nodes', () => {
expect(edges).toHaveLength(0);
});
// TODO: pressing backspace creates problems on webkit
test('deletable=false prevents deletion', async ({ page }) => {
const node = page.locator(`.${FRAMEWORK}-flow__node`).and(page.locator('[data-id="notDeletable"]'));
await expect(node).toHaveCSS('visibility', 'visible');
@@ -153,6 +152,7 @@ test.describe('Nodes', () => {
await expect(node).toBeAttached();
await node.click();
// pressing backspace breaks webkit
await page.keyboard.press('d');
await expect(node).toBeAttached();
@@ -198,8 +198,8 @@ test.describe('Nodes', () => {
await firstOutputHandle.hover();
await page.mouse.down();
// TODO: Does not work in SvelteFlow for whatever reason!?
// await secondOutputHandle.hover();
// Does not work in SvelteFlow for whatever reason!?
// but the following works...
const box = await secondOutputHandle.boundingBox();
await page.mouse.move(box!.x + 2, box!.y + 2);
@@ -229,8 +229,8 @@ test.describe('Nodes', () => {
await firstInputHandle.hover();
await page.mouse.down();
// TODO: Does not work in SvelteFlow for whatever reason!?
// await secondInputHandle.hover();
// Does not work in SvelteFlow for whatever reason!?
// but the following works...
const box = await secondInputHandle.boundingBox();
await page.mouse.move(box!.x + 2, box!.y + 2);

View File

@@ -172,13 +172,12 @@ test.describe('Pane non-default', () => {
});
});
test.describe('Pane activation keys', () => {
test.beforeEach(async ({ page }) => {
// Go to the starting url before each test.
await page.goto('/tests/generic/pane/activation-keys');
// test.describe('Pane activation keys', () => {
// test.beforeEach(async ({ page }) => {
// // Go to the starting url before each test.
// await page.goto('/tests/generic/pane/activation-keys');
// Wait till the edges are rendered
await page.waitForSelector('[data-id="first-edge"]', { timeout: 5000 });
});
// TODO
});
// // Wait till the edges are rendered
// await page.waitForSelector('[data-id="first-edge"]', { timeout: 5000 });
// });
// });