fix: address final PR review issues

This commit is contained in:
AEmotionStudio
2026-01-15 17:38:38 -08:00
parent 837fe7da87
commit 0cf992d528
6 changed files with 32 additions and 16 deletions
+8 -4
View File
@@ -20,7 +20,7 @@ import {
type ParameterItem
} from './NodeDataExtractor';
import { NodeSelector, type NodeListEntry, type NodeExecOrderEntry } from './NodeSelector';
import { WidgetEditorFactory, type WidgetEditorInstance } from './widget-editors';
import { WidgetEditorFactory, WidgetSyncManager, type WidgetEditorInstance } from './widget-editors';
interface InfoPanelElements {
panel: HTMLDivElement | null;
@@ -1068,9 +1068,10 @@ export class UIManager {
// Get and destroy the editor
const editor = this.activeEditors.get(editorKey);
if (editor) {
// Update the displayed value with the new value
const newValue = editor.getValue();
valueEl.textContent = formatWidgetValue(newValue);
// Get the actual constrained value from the widget (not the unconstrained input value)
// This ensures displayed value matches what was actually stored
const actualValue = WidgetSyncManager.getWidgetValue(parseInt(nodeId, 10), widgetName);
valueEl.textContent = formatWidgetValue(actualValue ?? editor.getValue());
editor.destroy();
this.activeEditors.delete(editorKey);
}
@@ -1373,6 +1374,9 @@ export class UIManager {
}
cleanup(): void {
// Clean up active editors to prevent memory leaks
this.cleanupEditors();
if (this.elements.panel && this.elements.panel.parentNode) {
this.elements.panel.parentNode.removeChild(this.elements.panel);
}
@@ -122,7 +122,10 @@ export class WidgetEditorFactory {
e.preventDefault();
e.stopPropagation();
const step = config.constraints?.step ?? 1;
let newValue = parseFloat(input.value) - step;
const currentVal = parseFloat(input.value);
// Handle NaN (empty input) - fall back to current value or min or 0
const baseValue = isNaN(currentVal) ? (config.constraints?.min ?? Number(config.currentValue) ?? 0) : currentVal;
let newValue = baseValue - step;
// Clamp to constraints
if (config.constraints?.min !== undefined) {
newValue = Math.max(config.constraints.min, newValue);
@@ -135,7 +138,10 @@ export class WidgetEditorFactory {
e.preventDefault();
e.stopPropagation();
const step = config.constraints?.step ?? 1;
let newValue = parseFloat(input.value) + step;
const currentVal = parseFloat(input.value);
// Handle NaN (empty input) - fall back to current value or min or 0
const baseValue = isNaN(currentVal) ? (config.constraints?.min ?? Number(config.currentValue) ?? 0) : currentVal;
let newValue = baseValue + step;
// Clamp to constraints
if (config.constraints?.max !== undefined) {
newValue = Math.min(config.constraints.max, newValue);
+4 -2
View File
@@ -8,6 +8,7 @@ import { escapeHtml } from "../shared/utils.js";
import { formatValue, getValueClass, getValueAttributes, formatWidgetValue } from "./ValueFormatter.js";
import { getCheckpointInfo, getImageInfo, getTextBoxContent, getImportantNodeParameters } from "./NodeDataExtractor.js";
import { NodeSelector } from "./NodeSelector.js";
import { WidgetSyncManager } from "./widget-editors/WidgetSyncManager.js";
import { WidgetEditorFactory } from "./widget-editors/WidgetEditorFactory.js";
class UIManager {
constructor(stateManager) {
@@ -772,8 +773,8 @@ class UIManager {
const editorKey = `${nodeId}:${widgetName}`;
const editor = this.activeEditors.get(editorKey);
if (editor) {
const newValue = editor.getValue();
valueEl.textContent = formatWidgetValue(newValue);
const actualValue = WidgetSyncManager.getWidgetValue(parseInt(nodeId, 10), widgetName);
valueEl.textContent = formatWidgetValue(actualValue ?? editor.getValue());
editor.destroy();
this.activeEditors.delete(editorKey);
}
@@ -1016,6 +1017,7 @@ class UIManager {
}
}
cleanup() {
this.cleanupEditors();
if (this.elements.panel && this.elements.panel.parentNode) {
this.elements.panel.parentNode.removeChild(this.elements.panel);
}
File diff suppressed because one or more lines are too long
@@ -72,24 +72,28 @@ class WidgetEditorFactory {
return (_a = config.onBlur) == null ? void 0 : _a.call(config);
});
decrementBtn.addEventListener("click", (e) => {
var _a, _b;
var _a, _b, _c;
e.preventDefault();
e.stopPropagation();
const step = ((_a = config.constraints) == null ? void 0 : _a.step) ?? 1;
let newValue = parseFloat(input.value) - step;
if (((_b = config.constraints) == null ? void 0 : _b.min) !== void 0) {
const currentVal = parseFloat(input.value);
const baseValue = isNaN(currentVal) ? ((_b = config.constraints) == null ? void 0 : _b.min) ?? Number(config.currentValue) ?? 0 : currentVal;
let newValue = baseValue - step;
if (((_c = config.constraints) == null ? void 0 : _c.min) !== void 0) {
newValue = Math.max(config.constraints.min, newValue);
}
input.value = String(newValue);
syncValue();
});
incrementBtn.addEventListener("click", (e) => {
var _a, _b;
var _a, _b, _c;
e.preventDefault();
e.stopPropagation();
const step = ((_a = config.constraints) == null ? void 0 : _a.step) ?? 1;
let newValue = parseFloat(input.value) + step;
if (((_b = config.constraints) == null ? void 0 : _b.max) !== void 0) {
const currentVal = parseFloat(input.value);
const baseValue = isNaN(currentVal) ? ((_b = config.constraints) == null ? void 0 : _b.min) ?? Number(config.currentValue) ?? 0 : currentVal;
let newValue = baseValue + step;
if (((_c = config.constraints) == null ? void 0 : _c.max) !== void 0) {
newValue = Math.min(config.constraints.max, newValue);
}
input.value = String(newValue);
File diff suppressed because one or more lines are too long