Fix to contextMenuFilter.js

This commit is contained in:
Daniel Lewis 2024-06-02 11:48:21 -06:00
parent 2e3aa47f61
commit e1557ea69b

View File

@ -1,14 +1,14 @@
import {app} from "../../scripts/app.js";
import { LiteGraph } from "../../lib/litegraph.core.js";
// Adds filtering to combo context menus
const ext = {
name: "Comfy.ContextMenuFilter",
init() {
const ctxMenu = LiteGraph.ContextMenu;
LiteGraph.ContextMenu = function (values, options) {
const ctx = ctxMenu.call(this, values, options);
class FilterContextMenu extends LiteGraph.ContextMenu {
constructor(values, options){
super(values, options);
// If we are a dark menu (only used for combo boxes) then add a filter input
if (options?.className === "dark" && values?.length > 10) {
@ -137,12 +137,11 @@ const ext = {
});
})
}
return ctx;
};
LiteGraph.ContextMenu.prototype = ctxMenu.prototype;
},
}
}
LiteGraph.ContextMenu = FilterContextMenu;
window.ContextMenu = FilterContextMenu;
}
}
app.registerExtension(ext);