Skip to content

Commit f4bdb08

Browse files
committed
fix: fix propagating events
1 parent ac6f57b commit f4bdb08

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

src/components/canvas/EventedComponent/EventedComponent.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ export class EventedComponent<
8787
}
8888

8989
public dispatchEvent(event: Event): boolean {
90-
const bubbles = event.bubbles || false;
91-
92-
if (bubbles || !this.isInteractive()) {
90+
if (!this.isInteractive()) {
9391
return this._dipping(this, event);
9492
} else if (this._hasListener(this, event.type)) {
9593
this._fireEvent(this, event);
94+
if (event.bubbles) {
95+
return this._dipping(this, event);
96+
}
9697
return false;
9798
}
9899
return false;

src/components/canvas/layers/graphLayer/GraphLayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class GraphLayer extends Layer<TGraphLayerProps, TGraphLayerContext> {
6767
super({
6868
canvas: {
6969
zIndex: 2,
70-
classNames: ["no-user-select"],
70+
classNames: ["no-user-select", "no-pointer-events"],
7171
transformByCameraPosition: true,
7272
},
7373
// HTML element creation is now separated into framework-specific layers

src/stories/Playground/GraphPlayground.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ import { TBlock } from "../../components/canvas/blocks/Block";
1414
import { random } from "../../components/canvas/blocks/generate";
1515
import { ConnectionLayer } from "../../components/canvas/layers/connectionLayer/ConnectionLayer";
1616
import { Graph, GraphState, TGraphConfig } from "../../graph";
17-
import { GraphBlock, GraphCanvas, HookGraphParams, useGraph, useGraphEvent, useLayer } from "../../react-components";
17+
import { TComponentState } from "../../lib/Component";
18+
import {
19+
GraphBlock,
20+
GraphCanvas,
21+
GraphLayer,
22+
GraphPortal,
23+
HookGraphParams,
24+
useGraph,
25+
useGraphEvent,
26+
useLayer,
27+
} from "../../react-components";
1828
import { useFn } from "../../react-components/utils/hooks/useFn";
29+
import { Layer, LayerContext, LayerProps } from "../../services/Layer";
1930
import { ECanChangeBlockGeometry } from "../../store/settings";
2031
import { EAnchorType } from "../configurations/definitions";
2132

@@ -331,7 +342,14 @@ export function GraphPLayground() {
331342
<Toolbox graph={graph} className="graph-tools-zoom button-group" />
332343
<GraphSettings className="graph-tools-settings" graph={graph} />
333344
</Flex>
334-
<GraphCanvas graph={graph} renderBlock={renderBlockFn} />
345+
<GraphCanvas graph={graph} renderBlock={renderBlockFn}>
346+
<GraphPortal className="no-pointer-events" zIndex={1} transformByCameraPosition={true}>
347+
<div>
348+
<h1>DevTools</h1>
349+
</div>
350+
</GraphPortal>
351+
<GraphLayer layer={SomeLayer} />
352+
</GraphCanvas>
335353
</Flex>
336354
</Flex>
337355
<Flex direction="column" grow={1} className="content" gap={6}>
@@ -351,4 +369,22 @@ export function GraphPLayground() {
351369
);
352370
}
353371

372+
class SomeLayer extends Layer<LayerProps, LayerContext, TComponentState> {
373+
constructor(props: LayerProps) {
374+
super({
375+
canvas: {
376+
zIndex: 100,
377+
transformByCameraPosition: true,
378+
},
379+
...props,
380+
});
381+
}
382+
383+
protected render(): void {
384+
super.render();
385+
this.context.ctx.fillStyle = "red";
386+
this.context.ctx.fillRect(0, 0, 100, 100);
387+
}
388+
}
389+
354390
export const Default: StoryFn = () => <GraphPLayground />;

0 commit comments

Comments
 (0)