Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getSlotMenuOptions.apply incorrectly applying arguments when right clicking on slots. #18

Closed
Trung0246 opened this issue Sep 16, 2024 · 4 comments

Comments

@Trung0246
Copy link

menuInfo = getSlotMenuOptions.apply(this, slot);

I think it should be something like this:

menuInfo = getSlotMenuOptions.apply(this, [slot]);
@Trung0246 Trung0246 changed the title getSlotMenuOptions.apply incorrectly applying arguments when right licking on slots. getSlotMenuOptions.apply incorrectly applying arguments when right clicking on slots. Sep 16, 2024
@ty0x2333
Copy link
Owner

ty0x2333 commented Oct 3, 2024

The line of code

menuInfo = getSlotMenuOptions.apply(this, slot); 

is fine.

Below is the location of the relevant code in litegraph.js:

jagenjo/litegraph.js - litegraph.d.ts

getSlotMenuOptions?(slot: INodeSlot): ContextMenuItem[];

Interface INodeSlot

export interface INodeSlot {
    name: string;
    type: string | -1;
    label?: string;
    dir?:
        | typeof LiteGraph.UP
        | typeof LiteGraph.RIGHT
        | typeof LiteGraph.DOWN
        | typeof LiteGraph.LEFT;
    color_on?: string;
    color_off?: string;
    shape?: SlotShape;
    locked?: boolean;
    nameLocked?: boolean;
}

@Trung0246

@ty0x2333 ty0x2333 closed this as completed Oct 3, 2024
@Trung0246
Copy link
Author

Trung0246 commented Oct 3, 2024

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply

I think you probably misunderstood. On recent update, right clicking on input/output slot will cause error when running that line of code, which will no longer shows the actual right click menu. Other node pack I saw where either using apply(this, [slot]) or call(this, ...slot).

Alternative approach is getSlotMenuOptions.call(this, ...slot); if you thinks using apply is undesirable.

@Trung0246
Copy link
Author

Trung0246 commented Oct 3, 2024

@ty0x2333 the web console should shows the error when right clicking on the slot, removing that line or changing the fix I suggested make everything works again. I can confirm ttNinterface.js:416 (from https://github.com/TinyTerra/ComfyUI_tinyterraNodes) is not the cause, it is just due to slot data passed from the incorrect call undefined where instead it should be the valid slot data.

image

@ty0x2333
Copy link
Owner

ty0x2333 commented Oct 3, 2024

Thank you. This is indeed a bug. I will release a minor version to fix it. @Trung0246

ty0x2333 added a commit that referenced this issue Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants