diff --git a/src/lib/litegraph/src/LGraph.ts b/src/lib/litegraph/src/LGraph.ts index ce6d8ff84..55c75107b 100644 --- a/src/lib/litegraph/src/LGraph.ts +++ b/src/lib/litegraph/src/LGraph.ts @@ -1054,7 +1054,14 @@ export class LGraph implements LinkNetwork, BaseLGraph, Serialisable g.isPointInside(x, y)) + // Iterate backwards through groups to find top-most + for (let i = this._groups.length - 1; i >= 0; i--) { + const group = this._groups[i] + if (group.isPointInside(x, y)) { + return group + } + } + return undefined } /** @@ -1064,7 +1071,14 @@ export class LGraph implements LinkNetwork, BaseLGraph, Serialisable g.isPointInTitlebar(x, y)) + // Iterate backwards through groups to find top-most + for (let i = this._groups.length - 1; i >= 0; i--) { + const group = this._groups[i] + if (group.isPointInTitlebar(x, y)) { + return group + } + } + return undefined } /**