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