Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Notable changes to `@bwin/sankey-plus`. Versions follow semantic versioning. See
### Fixed

- Edge-node placement validation no longer spreads large stage arrays, so graphs with very many incident links validate without a `RangeError`.
- Programmatic and assistive-technology clicks on the diagram background no longer open details for whichever subject happens to sit at the default viewport coordinates. Detail-zero clicks on a subject control still inspect and activate it.

## [2.0.0] - 2026-11-01

Expand Down
12 changes: 7 additions & 5 deletions src/SankeyDiagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -854,11 +854,13 @@ function SankeyDiagramRender<I = unknown, T = unknown>(
'[data-flow-subject]',
);
const subject =
e.detail === 0 && control
? {
kind: control.dataset.kind as SankeySubject['kind'],
key: control.dataset.key!,
}
e.detail === 0
? control
? {
kind: control.dataset.kind as SankeySubject['kind'],
key: control.dataset.key!,
}
: null
: locate(e);
const touch = gesture.current?.type === 'touch';
gesture.current = null;
Expand Down
36 changes: 36 additions & 0 deletions tests/browser/inspection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,42 @@ test('changing graphs clears an active keyboard inspection', async ({
expect(errors).toEqual([]);
});

test('programmatic clicks only inspect through a subject control', async ({
page,
}) => {
const errors = collectErrors(page);
await page.goto('/');
await waitForRender(page);

const subject = page.locator('[data-flow-subject][data-kind="node"]').first();
await expect(subject).toBeVisible({ timeout: 15_000 });
await subject.evaluate((el) =>
el.scrollIntoView({ block: 'center', inline: 'center' }),
);
await expect(subject).toBeInViewport({ ratio: 1 });
const box = await subject.boundingBox();
if (!box) throw new Error('Subject has no layout box.');
const click = {
detail: 0,
button: 0,
clientX: box.x + box.width / 2,
clientY: box.y + box.height / 2,
};

// The target is the SVG background even though the coordinates point at the
// subject, so detail-zero clicks must not use those coordinates for locating.
const canvas = page.locator('svg.flow-canvas[role="group"]');
await canvas.dispatchEvent('click', click);
await expect(page.getByRole('tooltip')).toBeHidden();
await expect(page.locator('[data-emphasis="faded"]')).toHaveCount(0);

// Assistive activation dispatches detail-zero clicks on the subject control.
await subject.dispatchEvent('click', click);
await expect(page.getByRole('tooltip')).toBeVisible();

expect(errors).toEqual([]);
});

test('pointer inspection opens the details', async ({ page }) => {
const errors = collectErrors(page);
await page.goto('/');
Expand Down
Loading