mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
- Fix infinite reinitialization loop by only validating stale widget.inputEl when it's actually in DOM - Improve findWidgetInputElement to specifically search for textarea for text widgets, avoiding mismatches with checkbox inputs on nodes like WanVideo Lora Select that have toggle switches - Add data-node-id based element search as primary strategy for better reliability across rendering modes - Fix autocomplete initialization to properly handle element DOM state transitions Fixes autocomplete failing after Canvas ↔ Vue DOM mode switches and WanVideo node always failing to trigger autocomplete. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import { app } from "../../scripts/app.js";
|
|
import { chainCallback, setupInputWidgetWithAutocomplete } from "./utils.js";
|
|
|
|
app.registerExtension({
|
|
name: "LoraManager.Prompt",
|
|
|
|
async beforeRegisterNodeDef(nodeType) {
|
|
if (nodeType.comfyClass === "Prompt (LoraManager)") {
|
|
chainCallback(nodeType.prototype, "onNodeCreated", function () {
|
|
this.serialize_widgets = true;
|
|
|
|
const textWidget = this.widgets?.[0];
|
|
if (!textWidget) {
|
|
return;
|
|
}
|
|
|
|
const originalCallback =
|
|
typeof textWidget.callback === "function" ? textWidget.callback : null;
|
|
|
|
textWidget.callback = setupInputWidgetWithAutocomplete(
|
|
this,
|
|
textWidget,
|
|
originalCallback,
|
|
"embeddings"
|
|
);
|
|
});
|
|
}
|
|
},
|
|
async loadedGraphNode(node) {
|
|
if (node.comfyClass == "Prompt (LoraManager)") {
|
|
const textWidget = node.widgets?.[0];
|
|
if (textWidget && !node.autocomplete) {
|
|
const { setupInputWidgetWithAutocomplete } = await import("./utils.js");
|
|
const modelType = "embeddings";
|
|
const autocompleteOptions = {
|
|
maxItems: 20,
|
|
minChars: 1,
|
|
debounceDelay: 200,
|
|
};
|
|
textWidget.callback = setupInputWidgetWithAutocomplete(node, textWidget, textWidget.callback, modelType, autocompleteOptions);
|
|
}
|
|
}
|
|
},
|
|
});
|