Skip to content

Commit

Permalink
kie-issues#980: On the DMN Editor it's not possible to use the Palett…
Browse files Browse the repository at this point in the history
…e if the focus is on another element (#2598)
  • Loading branch information
jomarko authored Sep 20, 2024
1 parent c1c736b commit e1a5c69
Show file tree
Hide file tree
Showing 41 changed files with 278 additions and 86 deletions.
10 changes: 9 additions & 1 deletion packages/dmn-editor/src/diagram/Palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export function Palette({ pulse }: { pulse: boolean }) {

const { maxHeight } = useInViewSelect(dmnEditorRootElementRef, nodesPalletePopoverRef);

const clearCurrentFocusToAllowDraggingNewNode = useCallback(() => {
(document.activeElement as any)?.blur?.();
}, []);

return (
<>
<RF.Panel position={"top-left"}>
Expand Down Expand Up @@ -162,7 +166,11 @@ export function Palette({ pulse }: { pulse: boolean }) {
</aside>
</RF.Panel>
{!settings.isReadOnly && (
<RF.Panel position={"top-left"} style={{ marginTop: "78px" }}>
<RF.Panel
position={"top-left"}
style={{ marginTop: "78px" }}
onMouseDownCapture={clearCurrentFocusToAllowDraggingNewNode}
>
<div ref={nodesPalletePopoverRef} style={{ position: "absolute", left: 0, height: 0, zIndex: -1 }} />
<aside className={`kie-dmn-editor--palette ${pulse ? "pulse" : ""}`}>
<div
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 24 additions & 12 deletions packages/dmn-editor/tests-e2e/drdArtifacts/addAssociation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.TEXT_ANNOTATION,
});

expect(await edges.get({ from: DefaultNodeName.BKM, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(await edges.get({ from: DefaultNodeName.BKM, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.BKM, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -70,7 +70,9 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.TEXT_ANNOTATION,
});

expect(await edges.get({ from: DefaultNodeName.DECISION, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.DECISION, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.DECISION, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -97,7 +99,7 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.TEXT_ANNOTATION,
});

expect(
await expect(
await edges.get({ from: DefaultNodeName.KNOWLEDGE_SOURCE, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(
Expand All @@ -121,7 +123,9 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.TEXT_ANNOTATION,
});

expect(await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -143,7 +147,7 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.TEXT_ANNOTATION,
});

expect(
await expect(
await edges.get({ from: DefaultNodeName.DECISION_SERVICE, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(
Expand All @@ -167,7 +171,9 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.TEXT_ANNOTATION,
});

expect(await edges.get({ from: DefaultNodeName.GROUP, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.GROUP, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.GROUP, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand Down Expand Up @@ -198,7 +204,7 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.BKM,
});

expect(await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.BKM })).toBeAttached();
await expect(await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.BKM })).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.BKM })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -218,7 +224,9 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.DECISION,
});

expect(await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.DECISION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.DECISION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.DECISION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -240,7 +248,7 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.KNOWLEDGE_SOURCE,
});

expect(
await expect(
await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.KNOWLEDGE_SOURCE })
).toBeAttached();
expect(
Expand All @@ -264,7 +272,9 @@ test.describe("Add edge - Association", () => {
to: DefaultNodeName.INPUT_DATA,
});

expect(await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.INPUT_DATA })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.INPUT_DATA })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.INPUT_DATA })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -287,7 +297,7 @@ test.describe("Add edge - Association", () => {
position: NodePosition.TOP,
});

expect(
await expect(
await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.DECISION_SERVICE })
).toBeAttached();
expect(
Expand Down Expand Up @@ -316,7 +326,9 @@ test.describe("Add edge - Association", () => {
position: NodePosition.TOP,
});

expect(await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.GROUP })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.GROUP })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.TEXT_ANNOTATION, to: DefaultNodeName.GROUP })).toEqual(
EdgeType.ASSOCIATION
);
Expand Down
23 changes: 22 additions & 1 deletion packages/dmn-editor/tests-e2e/drdArtifacts/addGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { TestAnnotations } from "@kie-tools/playwright-base/annotations";
import { test, expect } from "../__fixtures__/base";
import { DefaultNodeName, NodeType } from "../__fixtures__/nodes";

Expand All @@ -29,8 +30,28 @@ test.describe("Add node - Group", () => {
test("should add Group node from palette", async ({ palette, nodes, diagram }) => {
await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 100, y: 100 } });

expect(nodes.get({ name: DefaultNodeName.GROUP })).toBeAttached();
await expect(nodes.get({ name: DefaultNodeName.GROUP })).toBeAttached();
await expect(diagram.get()).toHaveScreenshot("add-group-node-from-palette.png");
});

test("should add multiple Group nodes from palette in a row", async ({ palette, nodes, diagram }) => {
test.info().annotations.push({
type: TestAnnotations.REGRESSION,
description: "https://github.com/apache/incubator-kie-issues/issues/980",
});

await palette.dragNewNode({ type: NodeType.GROUP, targetPosition: { x: 100, y: 100 } });
await palette.dragNewNode({
type: NodeType.GROUP,
targetPosition: { x: 300, y: 300 },
thenRenameTo: "Second Group",
});

await diagram.resetFocus();

await expect(nodes.get({ name: DefaultNodeName.GROUP })).toBeAttached();
await expect(nodes.get({ name: "Second Group" })).toBeAttached();
await expect(diagram.get()).toHaveScreenshot("add-2-group-nodes-from-palette.png");
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,29 @@ test.describe("Add node - Text Annotation", () => {
test("should add Text Annotation node from palette", async ({ palette, nodes, diagram }) => {
await palette.dragNewNode({ type: NodeType.TEXT_ANNOTATION, targetPosition: { x: 100, y: 100 } });

expect(nodes.get({ name: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(nodes.get({ name: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(diagram.get()).toHaveScreenshot("add-text-annotation-node-from-palette.png");
});

test("should add two Text Annotation nodes from palette in a row", async ({ palette, nodes, diagram }) => {
test.info().annotations.push({
type: TestAnnotations.REGRESSION,
description: "https://github.com/apache/incubator-kie-issues/issues/980",
});

await palette.dragNewNode({ type: NodeType.TEXT_ANNOTATION, targetPosition: { x: 100, y: 100 } });
await palette.dragNewNode({
type: NodeType.TEXT_ANNOTATION,
targetPosition: { x: 300, y: 300 },
thenRenameTo: "Second Text Annotation",
});

await diagram.resetFocus();

await expect(nodes.get({ name: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(nodes.get({ name: "Second Text Annotation" })).toBeAttached();
await expect(diagram.get()).toHaveScreenshot("add-2-text-annotation-nodes-from-palette.png");
});
});

test.describe("add from nodes", () => {
Expand All @@ -53,7 +73,9 @@ test.describe("Add node - Text Annotation", () => {
targetPosition: { x: 100, y: 300 },
});

expect(await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -71,7 +93,9 @@ test.describe("Add node - Text Annotation", () => {
targetPosition: { x: 100, y: 300 },
});

expect(await edges.get({ from: DefaultNodeName.DECISION, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.DECISION, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.DECISION, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -89,7 +113,7 @@ test.describe("Add node - Text Annotation", () => {
targetPosition: { x: 500, y: 500 },
});

expect(await edges.get({ from: DefaultNodeName.BKM, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(await edges.get({ from: DefaultNodeName.BKM, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.BKM, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand All @@ -112,7 +136,7 @@ test.describe("Add node - Text Annotation", () => {
targetPosition: { x: 500, y: 500 },
});

expect(
await expect(
await edges.get({ from: DefaultNodeName.DECISION_SERVICE, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(
Expand Down Expand Up @@ -142,7 +166,7 @@ test.describe("Add node - Text Annotation", () => {
targetPosition: { x: 100, y: 300 },
});

expect(
await expect(
await edges.get({ from: DefaultNodeName.KNOWLEDGE_SOURCE, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(
Expand All @@ -162,7 +186,9 @@ test.describe("Add node - Text Annotation", () => {
targetPosition: { x: 500, y: 500 },
});

expect(await edges.get({ from: DefaultNodeName.GROUP, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.GROUP, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.GROUP, to: DefaultNodeName.TEXT_ANNOTATION })).toEqual(
EdgeType.ASSOCIATION
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ test.describe("Delete edge - Association", () => {
targetPosition: { x: 100, y: 300 },
});

expect(await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })
).toBeAttached();
});

test("should delete an Association using the delete key", async ({ diagram, edges, nodes }) => {
await diagram.resetFocus();
await edges.delete({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION });

expect(
await expect(
await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })
).not.toBeAttached();

Expand All @@ -53,7 +55,7 @@ test.describe("Delete edge - Association", () => {
await diagram.resetFocus();
await edges.delete({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION, isBackspace: true });

expect(
await expect(
await edges.get({ from: DefaultNodeName.INPUT_DATA, to: DefaultNodeName.TEXT_ANNOTATION })
).not.toBeAttached();

Expand Down
32 changes: 28 additions & 4 deletions packages/dmn-editor/tests-e2e/drgElements/addBkm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { TestAnnotations } from "@kie-tools/playwright-base/annotations";
import { test, expect } from "../__fixtures__/base";
import { EdgeType } from "../__fixtures__/edges";
import { DefaultNodeName, NodeType } from "../__fixtures__/nodes";
Expand All @@ -31,7 +32,7 @@ test.describe("Add node - BKM", () => {
test("should add new BKM node from palette", async ({ jsonModel, palette, nodes, diagram }) => {
await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } });

expect(nodes.get({ name: DefaultNodeName.BKM })).toBeAttached();
await expect(nodes.get({ name: DefaultNodeName.BKM })).toBeAttached();
await expect(diagram.get()).toHaveScreenshot("add-bkm-node-from-palette.png");

// JSON model assertions
Expand All @@ -52,6 +53,25 @@ test.describe("Add node - BKM", () => {
"@_height": 80,
});
});

test("should add two new BKM nodes from palette in a row", async ({ palette, nodes, diagram }) => {
test.info().annotations.push({
type: TestAnnotations.REGRESSION,
description: "https://github.com/apache/incubator-kie-issues/issues/980",
});
await palette.dragNewNode({ type: NodeType.BKM, targetPosition: { x: 100, y: 100 } });
await palette.dragNewNode({
type: NodeType.BKM,
targetPosition: { x: 300, y: 300 },
thenRenameTo: "Second BKM",
});

await diagram.resetFocus();

await expect(nodes.get({ name: DefaultNodeName.BKM })).toBeAttached();
await expect(nodes.get({ name: "Second BKM" })).toBeAttached();
await expect(diagram.get()).toHaveScreenshot("add-2-bkm-nodes-from-palette.png");
});
});

test.describe("add from nodes", () => {
Expand All @@ -67,7 +87,7 @@ test.describe("Add node - BKM", () => {
targetPosition: { x: 100, y: 300 },
});

expect(await edges.get({ from: "BKM - A", to: DefaultNodeName.BKM })).toBeAttached();
await expect(await edges.get({ from: "BKM - A", to: DefaultNodeName.BKM })).toBeAttached();
expect(await edges.getType({ from: "BKM - A", to: DefaultNodeName.BKM })).toEqual(
EdgeType.KNOWLEDGE_REQUIREMENT
);
Expand All @@ -85,7 +105,9 @@ test.describe("Add node - BKM", () => {
targetPosition: { x: 500, y: 500 },
});

expect(await edges.get({ from: DefaultNodeName.DECISION_SERVICE, to: DefaultNodeName.BKM })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.DECISION_SERVICE, to: DefaultNodeName.BKM })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.DECISION_SERVICE, to: DefaultNodeName.BKM })).toEqual(
EdgeType.KNOWLEDGE_REQUIREMENT
);
Expand All @@ -103,7 +125,9 @@ test.describe("Add node - BKM", () => {
targetPosition: { x: 100, y: 300 },
});

expect(await edges.get({ from: DefaultNodeName.KNOWLEDGE_SOURCE, to: DefaultNodeName.BKM })).toBeAttached();
await expect(
await edges.get({ from: DefaultNodeName.KNOWLEDGE_SOURCE, to: DefaultNodeName.BKM })
).toBeAttached();
expect(await edges.getType({ from: DefaultNodeName.KNOWLEDGE_SOURCE, to: DefaultNodeName.BKM })).toEqual(
EdgeType.AUTHORITY_REQUIREMENT
);
Expand Down
Loading

0 comments on commit e1a5c69

Please sign in to comment.