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:
Glary-Bot
2026-05-14 22:54:30 +00:00
committed by Connor Byrne
parent 6dc819b15b
commit 8de8031ecb
2 changed files with 19 additions and 5 deletions

View File

@@ -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(' ')

View File

@@ -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(