Rename widget _displayValue to resolve conflict (#1025)

This commit is contained in:
filtered
2025-05-07 22:36:40 +10:00
committed by GitHub
parent 8cf449c957
commit 44c98fbf62
3 changed files with 7 additions and 6 deletions

View File

@@ -115,7 +115,8 @@ export abstract class BaseWidget<TWidget extends IWidget = IWidget> implements I
return this.label || this.name
}
get displayValue(): string {
// TODO: Resolve this workaround. Ref: https://github.com/Comfy-Org/litegraph.js/issues/1022
get _displayValue(): string {
return String(this.value)
}
@@ -171,9 +172,9 @@ export abstract class BaseWidget<TWidget extends IWidget = IWidget> implements I
const { margin } = BaseWidget
// Measure label and value
const { displayName, displayValue } = this
const { displayName, _displayValue } = this
const labelWidth = ctx.measureText(displayName).width
const valueWidth = ctx.measureText(displayValue).width
const valueWidth = ctx.measureText(_displayValue).width
const gap = BaseWidget.labelValueGap
const x = margin * 2 + leftPadding
@@ -218,7 +219,7 @@ export abstract class BaseWidget<TWidget extends IWidget = IWidget> implements I
area.setWidthRightAnchored(cappedValueWidth)
}
ctx.fillStyle = this.text_color
drawTextInArea({ ctx, text: displayValue, area, align: "right" })
drawTextInArea({ ctx, text: _displayValue, area, align: "right" })
}
/**

View File

@@ -22,7 +22,7 @@ function toArray(values: Values): string[] {
export class ComboWidget extends BaseSteppedWidget<IComboWidget> implements IComboWidget {
override type = "combo" as const
override get displayValue() {
override get _displayValue() {
const { values: rawValues } = this.options
if (rawValues) {
const values = typeof rawValues === "function" ? rawValues() : rawValues

View File

@@ -8,7 +8,7 @@ import { BaseSteppedWidget } from "./BaseSteppedWidget"
export class NumberWidget extends BaseSteppedWidget<INumericWidget> implements INumericWidget {
override type = "number" as const
override get displayValue() {
override get _displayValue() {
return Number(this.value).toFixed(
this.options.precision !== undefined
? this.options.precision