mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-23 22:25:05 +00:00
fix: address PR review (round 2)
- isValidGridTrack helper using CSS.supports('grid-template-rows', value),
cached per-string. Applied in gridTemplateRows so a bad persisted value
falls back to the existing auto/min-content default instead of breaking
the whole node's row layout.
- writeGridOverrides: skip node.properties initialization on empty
(clear) writes so clearing overrides on a node that never had any
properties stays a true no-op.
This commit is contained in:
@@ -42,6 +42,7 @@ import {
|
||||
getExecutionIdFromNodeData,
|
||||
getLocatorIdFromNodeData
|
||||
} from '@/utils/graphTraversalUtil'
|
||||
import { isValidGridTrack } from '@/utils/widgetGridOverrides'
|
||||
|
||||
interface ProcessedWidget {
|
||||
advanced: boolean
|
||||
@@ -424,7 +425,7 @@ export function useProcessedWidgets(
|
||||
return visibleWidgets.value
|
||||
.map((w) => {
|
||||
const override = overrides?.[w.slotName ?? w.name]
|
||||
if (override) return override
|
||||
if (override && isValidGridTrack(override)) return override
|
||||
return shouldExpand(w.type) || w.hasLayoutSize ? 'auto' : 'min-content'
|
||||
})
|
||||
.join(' ')
|
||||
|
||||
@@ -2,6 +2,19 @@ import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
|
||||
const GRID_OVERRIDES_PROPERTY_KEY = 'gridOverrides'
|
||||
|
||||
const gridTrackValidityCache = new Map<string, boolean>()
|
||||
|
||||
export function isValidGridTrack(value: string): boolean {
|
||||
const cached = gridTrackValidityCache.get(value)
|
||||
if (cached !== undefined) return cached
|
||||
const valid =
|
||||
typeof CSS !== 'undefined' &&
|
||||
typeof CSS.supports === 'function' &&
|
||||
CSS.supports('grid-template-rows', value)
|
||||
gridTrackValidityCache.set(value, valid)
|
||||
return valid
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps widget name -> CSS grid-template-rows track value
|
||||
* (e.g. '200px', 'minmax(150px, 300px)', '1fr', 'auto').
|
||||
@@ -25,12 +38,12 @@ function writeGridOverrides(
|
||||
node: LGraphNode,
|
||||
overrides: WidgetGridOverrides
|
||||
): void {
|
||||
node.properties ??= {}
|
||||
if (Object.keys(overrides).length === 0) {
|
||||
delete node.properties[GRID_OVERRIDES_PROPERTY_KEY]
|
||||
} else {
|
||||
node.properties[GRID_OVERRIDES_PROPERTY_KEY] = overrides
|
||||
if (node.properties) delete node.properties[GRID_OVERRIDES_PROPERTY_KEY]
|
||||
return
|
||||
}
|
||||
node.properties ??= {}
|
||||
node.properties[GRID_OVERRIDES_PROPERTY_KEY] = overrides
|
||||
}
|
||||
|
||||
export function setGridOverride(
|
||||
|
||||
Reference in New Issue
Block a user