Opening this to track a design question that came up during the select[multiple] prototype (#67563, #68350) - flagged by @leonsenft for broader team discussion.
The problem
isObject in type_guards.ts returns true for arrays (typeof [] === 'object'). This means a Field<string[]> passes the object check in structure.ts, Object.keys is called on the array value, and one child node per element is created ('0', '1', etc.). As the array length changes, those nodes churn.
For something like a multi-select, the selected values are atomic - there's no meaningful field('0'). The current field tree has no way to express that distinction.
Possible directions
- A
Leaf<T> wrapper that marks a value as opaque, suppressing child materialization regardless of type
Set<string> as the value type - Object.keys(new Set(...)) is [], so no child nodes with the current architecture
- A schema-level opt-out on the field's logic that suppresses child materialization for specific fields
Wondering whether others have thoughts on the right shape for this, especially given the broader Signal Forms API direction for v22+.
Opening this to track a design question that came up during the
select[multiple]prototype (#67563, #68350) - flagged by @leonsenft for broader team discussion.The problem
isObjectintype_guards.tsreturnstruefor arrays (typeof [] === 'object'). This means aField<string[]>passes the object check instructure.ts,Object.keysis called on the array value, and one child node per element is created ('0','1', etc.). As the array length changes, those nodes churn.For something like a multi-select, the selected values are atomic - there's no meaningful
field('0'). The current field tree has no way to express that distinction.Possible directions
Leaf<T>wrapper that marks a value as opaque, suppressing child materialization regardless of typeSet<string>as the value type -Object.keys(new Set(...))is[], so no child nodes with the current architectureWondering whether others have thoughts on the right shape for this, especially given the broader Signal Forms API direction for v22+.