Skip to content

Commit b618ebe

Browse files
authored
Change groupNode menu anchor to retain position (#3733)
1 parent b61640c commit b618ebe

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/extensions/core/groupNode.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ function addConvertToGroupOptions() {
15911591
const disabled =
15921592
selected.length < 2 ||
15931593
selected.find((n) => GroupNodeHandler.isGroupNode(n))
1594-
options.splice(index + 1, null, {
1594+
options.splice(index, null, {
15951595
content: `Convert to Group Node`,
15961596
disabled,
15971597
callback: convertSelectedNodesToGroupNode
@@ -1602,7 +1602,7 @@ function addConvertToGroupOptions() {
16021602
function addManageOption(options, index) {
16031603
const groups = app.graph.extra?.groupNodes
16041604
const disabled = !groups || !Object.keys(groups).length
1605-
options.splice(index + 1, null, {
1605+
options.splice(index, null, {
16061606
content: `Manage Group Nodes`,
16071607
disabled,
16081608
callback: () => manageGroupNodes()
@@ -1614,10 +1614,10 @@ function addConvertToGroupOptions() {
16141614
LGraphCanvas.prototype.getCanvasMenuOptions = function () {
16151615
// @ts-expect-error fixme ts strict error
16161616
const options = getCanvasMenuOptions.apply(this, arguments)
1617-
const index =
1618-
options.findIndex((o) => o?.content === 'Add Group') + 1 || options.length
1619-
addConvertOption(options, index)
1620-
addManageOption(options, index + 1)
1617+
const index = options.findIndex((o) => o?.content === 'Add Group')
1618+
const insertAt = index === -1 ? options.length - 1 : index + 2
1619+
addConvertOption(options, insertAt)
1620+
addManageOption(options, insertAt + 1)
16211621
return options
16221622
}
16231623

@@ -1627,10 +1627,9 @@ function addConvertToGroupOptions() {
16271627
// @ts-expect-error fixme ts strict error
16281628
const options = getNodeMenuOptions.apply(this, arguments)
16291629
if (!GroupNodeHandler.isGroupNode(node)) {
1630-
const index =
1631-
options.findIndex((o) => o?.content === 'Outputs') + 1 ||
1632-
options.length - 1
1633-
addConvertOption(options, index)
1630+
const index = options.findIndex((o) => o?.content === 'Properties')
1631+
const insertAt = index === -1 ? options.length - 1 : index
1632+
addConvertOption(options, insertAt)
16341633
}
16351634
return options
16361635
}

0 commit comments

Comments
 (0)